In the Determine if a Cell Is Reachable at a Given Time coding problem, you are given a starting point , a target point , and a time limit . In each second, you must move to any of the 8 adjacent cells (including diagonals). You need to determine if it is possible to be exactly at the target cell after exactly seconds.
Google asks this to test your ability to simplify geometric problems. While it might look like a BFS or pathfinding problem, the "8-way movement" makes it a simple distance calculation problem. It evaluations your understanding of Chebyshev distance and your ability to identify edge cases where the path might be too short to consume enough time.
This problem uses Coordinate Geometry (Chebyshev Distance).
minDist = max(abs(sx - fx), abs(sy - fy)).minDist > t, it is impossible to reach the target in time.false.true.Start: (1, 1), Target: (3, 3), .
max(abs(3-1), abs(3-1)) = 2.minDist (2) <= t (2). Result: true.
Start: (1, 1), Target: (1, 1), .false.Always look at the movement rules first. 4-way movement Manhattan Distance. 8-way movement Chebyshev Distance (Maximum of or ). Euclidean distance Straight line.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Check if Number is a Sum of Powers of Three | Medium | Solve | |
| Count Total Number of Colored Cells | Medium | Solve | |
| Factorial Trailing Zeroes | Medium | Solve | |
| Reverse Integer | Medium | Solve | |
| Alice and Bob Playing Flower Game | Medium | Solve |