Furthest Building You Can Reach
A medium-tier problem at 50% community acceptance, tagged with Array, Greedy, Heap (Priority Queue). Reported in interviews at oyo and 5 others.
You're climbing a series of buildings with a ladder and some bricks. You can reach a building only if you have enough materials to cover the height difference. The problem asks how far you can go before you run out. It's a deceptively simple greedy problem that trips up candidates who don't see the heap optimization. Acceptance is right around 50%, meaning half the people submitting a solution get it wrong or timeout. Companies like TikTok, Flipkart, and DE Shaw ask it regularly. If this problem hits your live assessment and you blank on the trick, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Furthest Building You Can Reach"
Furthest Building You Can Reach 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 Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.
Get StealthCoderThe naive approach is linear: try to greedily use your cheapest materials first. That fails because you might waste bricks on a tiny step and then face a huge jump with only ladders left. The real insight is a max heap. At each building, if you don't have enough materials, you look back at all the steps you've taken so far and swap out the most expensive one for the alternative resource (ladder for brick, or vice versa). This greedy swap-back strategy works because you're always minimizing total cost as you go. The topics are Array, Greedy, and Heap. Most candidates see 'greedy' and stop there. The heap is the pattern that separates the 50% who pass from the 50% who don't. Even if you haven't seen this exact problem, StealthCoder runs invisibly during screen share and surfaces a working solution the moment you're stuck.
Pattern tags
You know the problem.
Make sure you actually pass it.
Furthest Building You Can Reach 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 Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Furthest Building You Can Reach interview FAQ
Is this really asked at TikTok and Flipkart?+
Yes. Six companies report asking it, including TikTok, Flipkart, DE Shaw, and Dream11. It's a medium-difficulty slot filler in their online assessments. Not a signature question, but common enough that skipping it costs you.
What's the trick I'm missing if my greedy solution times out?+
You're probably greedily consuming resources from lowest cost to highest. That's O(n^2) or worse. The trick is a max heap: at each building, if you're short on materials, look back at all prior steps and swap the most expensive resource you used. That's O(n log n) and passes all cases.
How does the heap connect to the greedy and array topics?+
The array is your input. Greedy is the strategy: always make the locally optimal choice at each step. The heap is the data structure that makes greedy efficient by letting you quickly identify which prior decision to undo. All three topics work together.
Is 50% acceptance rate high or low for medium difficulty?+
It's below typical for medium. Most medium problems sit around 55-65% acceptance. This one sits exactly at 50%, meaning it's a gut-check problem. The gap between 'seems simple' and 'actually works' is real.
Can I solve this without a heap?+
Technically yes, but you'll timeout or need O(n^2) space and time. A heap gives you O(n log n) time and O(n) space, which is what the problem expects. For an online assessment, the heap approach is the only one that clears all test cases in time.
Want the actual problem statement? View "Furthest Building You Can Reach" on LeetCode →