1642. Furthest Building You Can Reach
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>