LeetCode 1156. Swap For Longest Repeated Character Substring in Java

In this post we will solve the LeetCode 1156. Swap For Longest Repeated Character Substring problem using the Java programming language.

You are given a string text. You can swap two of the characters in the text.

Return the length of the longest substring with repeated characters.

Constraints:

o 1 <= text.length <= 2 * 10^4
o text consist of lowercase English characters only.

Related Topics:

o String
o Sliding Window

We are given a string of English lowercase characters and we can swap two characters once in order to return the longest count of consecutive characters. Continue reading “LeetCode 1156. Swap For Longest Repeated Character Substring in Java”