Problem 1520 · Hard

Maximum Number of Non-Overlapping Substrings

Expand each letter’s first-to-last span until it is closed, then choose the non-overlapping spans by earliest right end.

Open the interactive visualisation