Data Structures & AlgorithmsModerateGATE CS · ICPC regional

4 × 5 grid, rows top to bottom ('#' = blocked, '.' = open): ..#.. / ..#.. / ..... / ...#.. Count the paths from top-left to bottom-right that move only RIGHT or DOWN and never enter a blocked cell. How many such paths exist?

  1. A. 3
  2. B. 17
  3. C. 20
  4. D. 4

Correct answer: A. 3

Counting right/down paths with DP gives 3; blocked cells contribute zero paths. Counting open cells instead of paths is a confusion of the two.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic