Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Furthest Building You Can Reach

You walk across buildings of the given heights. Moving to a lower or equal building is free; moving up costs the height difference in bricks, or one ladder (any height). With the given bricks and ladders, print the furthest building index you can reach.

Constraints

1 <= n <= 10^5 0 <= bricks <= 10^9 0 <= ladders <= n

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.