Data Structures & AlgorithmsVery hardICPC regional · Product Company SDE
Problem: On a 3×3 matrix [[9,9,4],[6,6,8],[2,1,1]], a strictly increasing path moves up, down, left or right between adjacent cells with increasing values. What is the length (number of cells) of the longest such path?
- A. 5
- B. 4
- C. 3
- D. 6
Correct answer: B. 4
Memoised DFS over strictly increasing neighbour edges gives the longest path from each cell. Using non-strict comparisons allows equal values and overcounts.
More Coding Interview Problems questions
- Problem: The Collatz sequence starts at n = 27 and repeatedly applies: n → n/2 if n is even, n → 3n+1 if n is odd, until n = 1. How many…
- Problem: For the same Collatz process starting at n = 27, what is the largest value that appears in the sequence?
- Problem: The digital root of a positive integer is obtained by repeatedly summing its decimal digits until a single digit remains. What is…
- Problem: How many integers n with 1 ≤ n ≤ 1000 have decimal digits summing to exactly 10?
- Problem: What is the smallest positive integer n such that n! is divisible by 10⁶ (that is, n! has at least six trailing zeros in base 10)?
- Problem: Children stand in a line with ratings [1, 0, 2]. Each child gets at least one candy, and a child with a higher rating than a…