Cure.fit | SDE | 25 November
curefit · Question · Posted Apr 2020
An undirected, connected graph of N nodes (labeled 0, 1, 2, ..., N-1) is given as graph. graph.length = N, and j != i is in the list graph[i] exactly once, if and only if nodes i and j are connected. Return the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges. Input: [[1,2,3],[0],[0],[0]] Output: 4 Explanation: One possible path is ...
The full answer & interview discussion are available to premium members.
Log in Create a free account