road: 'x' is a pothole and '.' is smooth pavement. You have a budget of budget.
On one trip the crew patches k potholes that sit next to each other with no gaps, and the trip costs k + 1. There can be any number of trips, and a trip may patch only part of a run of potholes.
Return the largest number of potholes you can repair without spending more than budget.road='xx.xxxx.x', budget=7 → 5
Fix the run of four potholes for 4 + 1 = 5. The remaining 2 pay for one more pothole from the pair, at 1 + 1 = 2. Five potholes in total.
road='x.x.x', budget=6 → 3
Each lone pothole costs 2, and the budget covers all three.
road='...', budget=4 → 0
The road is smooth; there is nothing to fix.
road consists only of the characters '.' and 'x'road='xx.xxxx.x', budget=7
5
Run checks the first 3 tests in your browser. Submit checks all 130 tests on the server, hidden ones included.