Data Structures & AlgorithmsModerateCodeforces Div 2 C · GATE CS

A grid has 4 rows and 3 columns with these values (top to bottom): 855 818 192 153 A path moves between side-adjacent cells (up, down, left or right) and each next cell must have a strictly larger value than the current cell. What is the largest number of cells on such a path?

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

Correct answer: A. 4

A memoised DFS from every start gives 4 cells. Restricting moves to right and down gives 2, and allowing equal values (non-decreasing paths) gives 3.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic