Furthest Building with Sandbags and Ropes
Updated
Problem statement
Given heights, the number of sandbags, and the number of ropes, return the largest building index you can reach.
You start at index 0 and move through the row of buildings in order. Moving to a building of equal or lower height is free. Moving up by d height units costs either d sandbags or one rope. A rope covers a climb of any height. You may choose which climbs use ropes as you go.
Function
furthestBuilding(heights: int[], sandbags: int, ropes: int) → intExamples
Example 1
heights = [4,2,7,6,9,14,12]sandbags = 5ropes = 1return = 4Use five sandbags for the climb from 2 to 7 and the rope for the climb from 6 to 9. Nothing is left for the next climb, so the furthest index is four.
Example 2
heights = [2,6,7]sandbags = 1ropes = 1return = 2Use the rope for the climb of four and one sandbag for the last climb. You reach the last building, index two.
Example 3
heights = [1,5,2,6]sandbags = 4ropes = 0return = 2The first climb uses all four sandbags, and the drop after it is free. The last climb cannot be paid for, so you stop at index two.
Constraints
1 <= heights.length <= 100000.1 <= heights[i] <= 1000000.0 <= sandbags <= 1000000000.0 <= ropes <= heights.length.
More Bloomberg LP Phone Screen questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Task SchedulerAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
- Defer Expenses to Preserve BalanceDRW · PHONE SCREENDRW interview questions
- Minimum Bus Fleet Across StationsSnowflake · PHONE SCREENSnowflake interview questions
- Minimize Array Sum After K Halving OperationsDocuSign · PHONE SCREENDocuSign interview questions
- Automation Pipeline, Part 3: Stage DurationPlaid · PHONE SCREENPlaid interview questions
- Assign Pins to the Shortest ColumnPinterest · PHONE SCREENPinterest interview questions
- Furthest Building with Sandbags and RopesZip · PHONE SCREENZip interview questions
- Minimum Sum After K Ceiling HalvingsAdobe · PHONE SCREENAdobe interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)