text of lowercase English letters. Cut it into consecutive pieces so that no letter appears twice within any piece. Every character of the string goes into exactly one piece.
Return the smallest possible number of pieces.text="banana" → 3
For example ban + an + a: each piece has distinct letters. Two pieces are not enough: banana has three as and a piece can hold only one.
text="queue" → 2
que + ue.
text="dog" → 1
All letters differ, so one piece is enough.
text consists of lowercase English letterstext="banana"
3
Run checks the first 3 tests in your browser. Submit checks all 106 tests on the server, hidden ones included.