Problem 2981 · Medium

Find Longest Special Substring That Occurs Thrice I

For each letter, keep the three largest candidate run-based lengths; the third one is the answer for that letter.

Open the interactive visualisation