aabccc becomes a2bc3, and abc does not change. A run is always a maximal block of equal letters: aaaa is a4, not a2a2.
You are given a string text and an integer budget. Before compressing, you may delete at most budget characters of text, any you like (the rest keep their order). Return the smallest length of the compressed string you can achieve.text='xxxyzzzzw', budget=2 → 4
Without deletions the code is x3yz4w, length 6. Deleting y and w leaves xxxzzzz, whose code x3z4 has length 4.
text='pqppp', budget=1 → 2
Delete q to get pppp, coded as p4.
text='bbbbbbbbbbbb', budget=3 → 2
Twelve bs are coded as b12 (length 3). Deleting three of them leaves b9, of length 2.
text.length ≤ 120budget ≤ text.lengthtext consists of lowercase English letters onlytext='xxxyzzzzw', budget=2
4
Run checks the first 3 tests in your browser. Submit checks all 87 tests on the server, hidden ones included.