You are given an integer array heights where heights[i] is the height of building i. You start at building i + 1 from building i for increasing i.
If heights[i + 1] <= heights[i], you can move to the next building without spending any resources. If heights[i + 1] > heights[i], you must cover the height difference heights[i + 1] - heights[i] by using either:
a number of bricks equal to that difference, or
one of your ladders.
Return the index of the furthest building you can reach.
Constraints:
heights.length
heights[i]
bricks
ladders heights.length
You are given an integer array heights where heights[i] is the height of building i. You start at building i + 1 from building i for increasing i.
If heights[i + 1] <= heights[i], you can move to the next building without spending any resources. If heights[i + 1] > heights[i], you must cover the height difference heights[i + 1] - heights[i] by using either:
a number of bricks equal to that difference, or
one of your ladders.
Return the index of the furthest building you can reach.
Constraints:
heights.length
heights[i]
bricks
ladders heights.length