MEDIUMasked at 1 company

K Highest Ranked Items Within a Price Range

A medium-tier problem at 45% community acceptance, tagged with Array, Breadth-First Search, Sorting. Reported in interviews at Booking.com and 0 others.

Founder's read

You're filtering and ranking items by price and score, and the naive approach will time out on your live OA. This problem is asked at Booking.com and tests whether you can sort or heap correctly when you can't just brute-force all candidates. The pattern feels like a filter-then-sort, but the trick is knowing when to stop early. If you blank on the optimization during your assessment, StealthCoder surfaces a working solution invisible to the proctor in seconds.

Companies asking
1
Difficulty
MEDIUM
Acceptance
45%

Companies that ask "K Highest Ranked Items Within a Price Range"

If this hits your live OA

K Highest Ranked Items Within a Price Range is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The gotcha here is that a straight sort on all matching items wastes time and memory. You need to either use a min-heap to track only the top K as you iterate, or recognize that sorting the price range first lets you bail early. The problem tags array, sorting, and heap for a reason: candidates often miss that heap (priority queue) is the efficient path when K is small relative to the price range size. Common failure point is sorting the entire filtered list and then taking top K. That works for correctness but bombs on large datasets. The real solution maintains a heap of size K, pushing candidates in and popping the worst one when heap exceeds K. StealthCoder is your safety net if the heap optimization doesn't click during the timed assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

K Highest Ranked Items Within a Price Range recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

K Highest Ranked Items Within a Price Range interview FAQ

Is this problem actually hard or just annoying?+

Medium difficulty with a 44.8% pass rate means it's a screening filter, not a gimme. Most candidates solve it correctly but slow. The annoying part isn't the logic, it's realizing you need a heap to stay under time limits. The trick is the optimization, not the core algorithm.

Do I really need a heap or does sorting work?+

Sorting works for correctness but fails on large price ranges with small K. Heap lets you process items and keep only top K in memory, exiting early. If K is 5 and you have 100,000 items in range, heap wins hard. Sorting the whole thing gets you time limit exceeded.

How does this relate to the array and sorting tags?+

You're iterating an array and filtering by price range (array work), then maintaining the K highest by score (sorting/heap work). The array structure matters for how you access items; the sorting tags tell you the optimization lever is in how you rank them, not just iterating.

Will Booking.com ask this the same way every time?+

Booking.com likely rotates variations on this pattern. The core stays the same: filter by constraint, rank by score, return top K. Variations might swap in different constraints or scoring rules. The heap insight transfers to all of them.

What's the easiest way to think about the heap approach?+

Imagine a leaderboard of your top K items. As you see new candidates in the price range, compare each to the worst person on your leaderboard. If the new candidate is better, swap them in. Once you've checked all candidates, your leaderboard is your answer. That's the heap.

Want the actual problem statement? View "K Highest Ranked Items Within a Price Range" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.