category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

1642. Furthest Building You Can Reach

Explanation similar to

Implementation ```cpp int furthestBuilding(vector& heights, int bricks, int ladders) { int n = heights.size(); priority_queue<int, vector, greater> pq; for (int i = 1; i < n; i++) { int diff = heights[i] - heights[i - 1]; if (0 < diff) { pq.push(diff); } if (ladders < pq.size()) { bricks -= pq.top(); pq.pop(); } if (bricks < 0) { return i - 1; } } return n - 1; } ``` </details>