Furthest Building You Can Reach

You are given an integer array representing the heights of buildings, with a certain number of bricks and ladders. Starting from the first building, move to subsequent buildings using either bricks or ladders when going to a taller building. The goal is to determine the furthest building index you can reach with the optimal use of the resources available.

Constraints

  • 1 <= heights.length <= 100000
  • 1 <= heights[i] <= 1000000
  • 0 <= bricks <= 1000000000
  • 0 <= ladders <= heights.length
Saving… · 3 lines
class Solution:
def furthestBuildingYouCanReach(self, heights, bricks, ladders):
pass
Console

Click Run to execute sample tests.