Data Structures & AlgorithmsHardProduct Company SDE · ICPC regional

Problem: Starting from an empty tree of directed edges, a DAG has edges 0→1, 0→2, 1→3, 2→3, 2→4, 3→5, 4→5, 1→4. How many distinct directed paths go from vertex 0 to vertex 5?

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

Correct answer: B. 4

Path counting on a DAG is a memoised sum over out-neighbours. Counting only the shortest paths, or counting vertices reachable, gives different values.

More Coding Interview Problems questions

Exams that ask this topic