Data Structures & AlgorithmsHardTCS NQT · Product Company SDE
Problem: A grid of 3×3 cells is numbered 1 to 9 row by row. Starting at 1 (top-left), the robot moves right or down. The number of paths that visit the centre cell (value 5) is what value?
- A. 5
- B. 3
- C. 6
- D. 4
Correct answer: D. 4
There are 6 monotone paths from top-left to bottom-right. Two reach the centre from the top-left and two leave it toward the bottom-right, so 2 × 2 = 4 paths pass through the centre.
More Coding Interview Problems questions
- Problem: A list of intervals is [1,5], [2,3], [4,8], [7,9], [10,11]. Merge all overlapping intervals (touching at an endpoint counts as…
- Problem: The string "aabbbcccc" is encoded by writing each letter followed by its count, e.g. "a2b3c4". What is the length of the encoded…
- Problem: What is the number of inversions in the array [2, 5, 1, 4, 3]?
- Problem: The array [3, 7, 1, 9] is used to create all non-empty contiguous subarrays. How many of them have an odd sum?
- Problem: In the array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], find the number of pairs (i, j) with i < j whose product is a multiple of 12.
- Problem: How many 5-digit numbers (10000–99999) have digits that sum to exactly 6 and begin with the digit 1?