text of lowercase English letters. In one move you may:
- erase the whole string;
- or erase the first i letters if the very next i letters are the same (1 ≤ i ≤ len(text) / 2).
For example, in "cdcde" you may erase the start "cd" because "cd" follows right after it, leaving "cde".
Return the largest number of moves in which the string can be erased completely.text="xyxyz" → 2
Peel off "xy" (it is followed by "xy" again) to get "xyz", then erase the rest. Two moves.
text="bbbb" → 4
Peel off one "b" three times, then erase the last one with the fourth move.
text="abcab" → 1
No prefix is immediately repeated, so the only move is to erase the whole string.
text consists of lowercase English letterstext="xyxyz"
2
Run checks the first 3 tests in your browser. Submit checks all 106 tests on the server, hidden ones included.