Tap here to switch tabs
Problem
Submissions

Problem: Smallest Substring With Identical Characters I

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

Statement

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

You are allowed to perform at most numOps operations on s. In a single operation, you can choose any index in s and flip the character at that position (changing '0' to '1' or '1' to '0').

Return the minimum possible length of the longest substring consisting of identical characters that can be achieved after at most numOps operations.

Constraints:

  • 1≤1 \leq n ==== s.length ≤1000\leq 1000

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

  • 0≤0 \leq numOps ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Smallest Substring With Identical Characters I

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

Statement

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

You are allowed to perform at most numOps operations on s. In a single operation, you can choose any index in s and flip the character at that position (changing '0' to '1' or '1' to '0').

Return the minimum possible length of the longest substring consisting of identical characters that can be achieved after at most numOps operations.

Constraints:

  • 1≤1 \leq n ==== s.length ≤1000\leq 1000

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

  • 0≤0 \leq numOps ≤\leq n