Data Structures & AlgorithmsVery hardICPC regional · GATE CS

Problem: A lattice path goes from (0,0) to (3,3) using steps right (1,0) and up (0,1), and it must never go above the diagonal (that is, at every point the x-coordinate is at least the y-coordinate). How many such paths exist?

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

Correct answer: A. 5

These are ballot-type paths counted by Catalan numbers; the DP that forbids points with y > x gives the count. Counting all C(6,3) = 20 monotone paths ignores the diagonal restriction.

More Coding Interview Problems questions

Exams that ask this topic