The K Highest Ranked Items interview question asks you to find the "best" items in a grid starting from a specific coordinate. Items are ranked by four criteria in order:
priceRange and reachable (not blocked by walls) are considered.Companies like Booking.com use this to test a candidate's mastery of Breadth-First Search (BFS) and Custom Sorting. It evaluations your ability to handle multi-level tie-breaking and grid traversal. It’s a comprehensive Matrix interview pattern that combines pathfinding with ranking.
This problem follows the BFS with Priority Queue Ranking pattern.
priceRange, store it as a candidate along with its distance, price, and coordinates.Start (0,0), Prices: [[1, 2], [0, 1]], Price Range: [1, 2], .
[[0,0], [1,1]].Practice using a Comparator or a lambda function for complex sorting. In many BFS interview patterns, the sorting logic is just as important as the traversal itself.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Cut Off Trees for Golf Event | Hard | Solve | |
| Trapping Rain Water II | Hard | Solve | |
| Kth Smallest Element in a Sorted Matrix | Medium | Solve | |
| Maximum Sum With at Most K Elements | Medium | Solve | |
| Maximum Number of Points From Grid Queries | Hard | Solve |