Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture
Problem: A grid of 4×4 cells holds the value r + c (0-indexed). Starting from the top-left corner, what is the maximum total of values along a path that moves only right or down to the bottom-right corner (both endpoints included)?
- A. 15
- B. 35
- C. 48
- D. 21
Correct answer: D. 21
Every right/down path visits exactly one cell on each anti-diagonal r + c = k for k = 0..6, so every path totals 0 + 1 + … + 6 = 21 and the DP max is also 21. Dropping the end cell gives 15, using 1-indexed values gives 35, and 48 is the sum of the whole grid.
More Coding Interview Problems questions
- Problem: A string is compressed by replacing each maximal run of equal letters with the letter and its count, only when the count is at…
- Problem: Pancake sort uses only prefix reversals on [3, 1, 2]. For each size from n down to 2, bring the largest value of the unsorted…
- Problem: In the array [2, 7, 11, 15, 3, 8], how many pairs i < j have a[i] + a[j] equal to a multiple of 5?
- Problem: The binary search for a value in the sorted array [2, 5, 8, 12, 16, 23, 38, 56, 72, 91] is run with the standard midpoint mid =…
- Problem: The bit string 1011001 is read as a binary number. What is its value when each bit is XOR-ed with the previous bit (the first bit…
- Problem: How many monotone right/down paths go from (0,0) to (3,3) on a 4 x 4 grid when cell (1,2) is blocked? Run the DP. python g = [[0]…