Problem 2982 · Medium

Find Longest Special Substring That Occurs Thrice II

Same run-candidate idea as the first version, with the candidate lists kept to three per letter so the scan stays linear.

Open the interactive visualisation