Tap here to switch tabs
Problem
Submissions

Problem: Swap For Longest Repeated Character Substring

Swap For Longest Repeated Character Substring asks you to return the maximum length of identical-character substring after swapping any two characters at most once.

Statement

Given a string text, you are allowed to swap any 22 characters at most 11 time.

Return the maximum length of a contiguous substring consisting of identical characters that can be obtained.

Constraints:

  • 1≤1 \leq text.length ≤2⋅104\leq 2 \cdot 10^4

  • text consists of lowercase English characters only.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Swap For Longest Repeated Character Substring

Swap For Longest Repeated Character Substring asks you to return the maximum length of identical-character substring after swapping any two characters at most once.

Statement

Given a string text, you are allowed to swap any 22 characters at most 11 time.

Return the maximum length of a contiguous substring consisting of identical characters that can be obtained.

Constraints:

  • 1≤1 \leq text.length ≤2⋅104\leq 2 \cdot 10^4

  • text consists of lowercase English characters only.