In this geometry/chess hybrid problem, you are given the positions of three pieces on an board: a white Rook, a white Bishop, and a black Queen. The Queen doesn't move. You need to find the minimum number of moves to capture the Queen using either the Rook or the Bishop.
The catch? The pieces cannot "jump over" each other. If the Bishop is between the Rook and the Queen, the Rook cannot capture the Queen in one move.
Goldman Sachs and Wipro use this to test Conditional Logic and Geometry intuition. It’s not about finding a path using BFS; it’s about checking for "blocks" along horizontal, vertical, and diagonal lines. Key competencies:
The pattern is Geometric Case Analysis.
Rook: (1, 1), Bishop: (1, 4), Queen: (1, 8)
Rook and Queen are in the same row (1). But the Bishop is at (1, 4), which is between column 1 and column 8.
The Rook is blocked. It cannot capture in 1 move.
Can the Bishop capture? It's at (1, 4) and Queen is at (1, 8). Not on a diagonal.
So the answer will be 2 moves.
(r1, c1) and (r2, c2) are on the same diagonal if abs(r1 - r2) == abs(c1 - c2).Always look for the upper bound. In chess, a Rook can reach any square in 2 moves. A Bishop can reach any square of its color in 2 moves. This limits the possible answers to 1 or 2, which simplifies your task to just checking the "1-move" conditions.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Minimum Cost to Set Cooking Time | Medium | Solve | |
| Number of Ways to Buy Pens and Pencils | Medium | Solve | |
| Smallest Greater Multiple Made of Two Digits | Medium | Solve | |
| Sum of Number and Its Reverse | Medium | Solve | |
| Consecutive Numbers Sum | Hard | Solve |