Data Structures & AlgorithmsHardCodeforces Div 2 D · ICPC regional

A grid has 3 rows and 4 columns with these values (top to bottom): 4179 9341 9892 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. 5
  2. B. 4
  3. C. 7
  4. D. 6

Correct answer: A. 5

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

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic