Data Structures & AlgorithmsModerateProduct-company MCQ pattern

A robot moves only right or down on a 3 × 4 grid of cells (3 rows, 4 columns) from the top-left cell to the bottom-right cell. The cell in row 2, column 2 (counting from 1) is blocked. How many paths are there?

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

Correct answer: B. 4

Without the block there are C(5, 2) = 10 paths. Paths through (2, 2) number C(2, 1) × C(3, 1) = 2 × 3 = 6, so 10 − 6 = 4; the DP table that sets the blocked cell to 0 gives the same.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic