Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Potholes That Can Be Fixed

med
30 min
Try to solve the Maximum Number of Potholes That Can Be Fixed problem.

Statement

You are given a string road and an integer budget.

The string road represents the condition of a road, where:

  • '.' represents a smooth surface.

  • 'x' represents a pothole.

Repairing a contiguous sequence of kk potholes costs k+1k + 1 units of budget.

Return the maximum total number of potholes that can be repaired within the given budget.

Constraints:

  • 1≤1 \leq road.length ≤105\leq 10^5

  • 1≤1 \leq budget ≤105+1\leq 10^5 + 1

  • road consists only of characters '.' and 'x'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Number of Potholes That Can Be Fixed

med
30 min
Try to solve the Maximum Number of Potholes That Can Be Fixed problem.

Statement

You are given a string road and an integer budget.

The string road represents the condition of a road, where:

  • '.' represents a smooth surface.

  • 'x' represents a pothole.

Repairing a contiguous sequence of kk potholes costs k+1k + 1 units of budget.

Return the maximum total number of potholes that can be repaired within the given budget.

Constraints:

  • 1≤1 \leq road.length ≤105\leq 10^5

  • 1≤1 \leq budget ≤105+1\leq 10^5 + 1

  • road consists only of characters '.' and 'x'.