Problem 3104 · Medium

Find Longest Self-Contained Substring

Grow a candidate substring from each first occurrence, and keep the longest one whose letters never appear outside it.

Open the interactive visualisation