Data Structures & AlgorithmsHardICPC regional · Codeforces Div2 D

Problem: In the undirected graph with edges 0-1, 0-2, 1-2, 1-3, 2-3, 3-4, how many simple paths (no repeated vertex) go from vertex 0 to vertex 4? Paths are counted as sequences of vertices.

  1. A. 5
  2. B. 4
  3. C. 3
  4. D. 6

Correct answer: B. 4

Enumerate simple paths by DFS with a visited set; every route to vertex 4 ends at its only neighbour 3. Counting shortest paths only gives a smaller count.

More Coding Interview Problems questions

Exams that ask this topic