Tap here to switch tabs
Problem
Submissions

Problem: Smallest Substring With Identical Characters II

Smallest Substring With Identical Characters II asks you to flip at most a given number of characters in a binary string and return the shortest possible length of its longest uniform substring.

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

Smallest Substring With Identical Characters II asks you to flip at most a given number of characters in a binary string and return the shortest possible length of its longest uniform substring.

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