text of lowercase English letters. Cut it into consecutive pieces so that every letter occurs in at most one piece: all occurrences of a letter must end up in the same piece.
Make as many pieces as possible. Joined in order, the pieces give back the original string.
Return the list of piece lengths from left to right.text="abacdcdefe" → [3, 4, 3]
The pieces are "aba", "cdcd" and "efe": each letter lives in one piece only. No finer cut works: cutting off "ab", for instance, would separate the two a's.
text="xyzzx" → [5]
The letter x appears at both ends, so the whole string is a single piece.
text="qrs" → [1, 1, 1]
text consists of lowercase English letterstext="abacdcdefe"
[3, 4, 3]
Run checks the first 3 tests in your browser. Submit checks all 67 tests on the server, hidden ones included.