Skip to content

Commit 706384a

Browse files
add skeleton for 847
1 parent 00d737c commit 706384a

File tree

1 file changed

+32
-0
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fishercoder.solutions;
2+
3+
/**
4+
* 847. Shortest Path Visiting All Nodes
5+
*
6+
* An undirected, connected graph of N nodes (labeled 0, 1, 2, ..., N-1) is given as graph.
7+
* graph.length = N, and j != i is in the list graph[i] exactly once, if and only if nodes i and j are connected.
8+
* Return the length of the shortest path that visits every node.
9+
* You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges.
10+
*
11+
* Example 1:
12+
* Input: [[1,2,3],[0],[0],[0]]
13+
* Output: 4
14+
* Explanation: One possible path is [1,0,2,0,3]
15+
*
16+
* Example 2:
17+
* Input: [[1],[0,2,4],[1,3,4],[2],[1,2]]
18+
* Output: 4
19+
* Explanation: One possible path is [0,1,4,2,3]
20+
*
21+
* Note:
22+
* 1 <= graph.length <= 12
23+
* 0 <= graph[i].length < graph.length
24+
* */
25+
public class _847 {
26+
public static class Solution1 {
27+
public int shortestPathLength(int[][] graph) {
28+
//TODO: implement this
29+
return -1;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)