Tap here to switch tabs
Problem
Submissions

Problem: Smallest Substring With Identical Characters II

med
30 min
Try to solve the Smallest Substring With Identical Characters II problem.

Statement

You are given a binary string s of length n and an integer numOps.

In one operation, you can choose any character in s and flip it, changing '0' to '1' or '1' to '0'.

Return the minimum possible length of the longest substring consisting of identical characters after performing at most numOps operations.

Constraints:

  • 1≤n==1 \leq n == s.length ≤105\leq 10^5

  • s consists only of '0' and '1'.

  • 0≤0 \leq numOps ≤n\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Smallest Substring With Identical Characters II

med
30 min
Try to solve the Smallest Substring With Identical Characters II problem.

Statement

You are given a binary string s of length n and an integer numOps.

In one operation, you can choose any character in s and flip it, changing '0' to '1' or '1' to '0'.

Return the minimum possible length of the longest substring consisting of identical characters after performing at most numOps operations.

Constraints:

  • 1≤n==1 \leq n == s.length ≤105\leq 10^5

  • s consists only of '0' and '1'.

  • 0≤0 \leq numOps ≤n\leq n