Data Structures & AlgorithmsHardTCS NQT · Product Company SDE
Problem: On a 6×6 grid, a robot starts at the top-left corner and moves only right or down to the bottom-right corner. The cells (1,2), (2,4), (3,1) and (4,3) (row, column, 0-indexed) are blocked. How many distinct paths exist?
- A. 54
- B. 252
- C. 30
- D. 63
Correct answer: C. 30
Each open cell takes paths from above plus from the left and every blocked cell holds 0, giving 30. With no blocks the count is C(10, 5) = 252; forgetting to zero (3,1) or (2,4) gives 54, and forgetting (1,2) or (4,3) gives 63.
More Coding Interview Problems questions
- Problem: Place 4 non-attacking rooks on a 4×4 board (no two share a row or column) such that none is on a forbidden cell. Forbidden cells…
- Problem: In a grid of 0s and 1s, a connected region is a group of 1-cells that are connected when moving to 8 neighbours (up, down, left…
- Problem: A rooted tree is given by parent array p = [-1, 0, 0, 1, 1, 2, 5, 5, 3] for nodes 0–8 (node 0 is the root). How many nodes are at…
- Problem: A max-heap starts with the values 9, 8, 6, 5, 4, 3, 1 (inserted in that order). Then three times in succession: pop the maximum…
- Problem: The string "abcbaxyzzyxq" is given. What is the minimum number of characters that must be deleted so the remaining string is a…
- Problem: A string is formed by writing the letters of "kayak" then "level" then "rotor". How many substrings of length 5 of…