text of lowercase English letters and an integer slack. For every letter present in the string, count how many times it occurs. Call the string even if any two of these counts differ by at most slack.
You may delete characters from the string. A letter that is deleted completely no longer counts. Return the smallest number of deletions that makes the string even.text="banana", slack=0 → 2
The counts are a: 3, n: 2, b: 1. Remove the b and one a, leaving two as and two ns.
text="mississippi", slack=1 → 3
The counts are m: 1, i: 4, s: 4, p: 2. For instance, drop the m, one i and one s: the counts 3, 3 and 2 differ by at most 1.
text="abc", slack=0 → 0
Each letter appears once, so the string is already even.
text consists of lowercase English letterstext="banana", slack=0
2
Run checks the first 3 tests in your browser. Submit checks all 56 tests on the server, hidden ones included.