Problem 1156 · Medium

Swap For Longest Repeated Character Substring

Find the longest run of a repeated character that can be extended by at most one swap with another occurrence of that character elsewhere in the string. The visual highlights runs and the swap that bridges two of them.

Open the interactive visualisation