Data Structures & AlgorithmsHardTCS NQT · Product Company SDE

Problem: On a 6×6 grid, a robot starts at the top-left corner and moves only right or down to the bottom-right corner. The cells (1,2), (2,4), (3,1) and (4,3) (row, column, 0-indexed) are blocked. How many distinct paths exist?

  1. A. 54
  2. B. 252
  3. C. 30
  4. D. 63

Correct answer: C. 30

Each open cell takes paths from above plus from the left and every blocked cell holds 0, giving 30. With no blocks the count is C(10, 5) = 252; forgetting to zero (3,1) or (2,4) gives 54, and forgetting (1,2) or (4,3) gives 63.

More Coding Interview Problems questions

Exams that ask this topic