You are given a string s. You should return the minimum number of deletions to obtain a word with even frequency of each character.
Constraints:
Input within the a-z charset.
Test cases:
My solution:
// Time: O(N)
// Space: O(1)
var counter = new int[26];
for (int i = 0; i < S.Length; i++)
counter[S[i] - 'a']++;
var numRemove = 0;
for (int i = 0; i < counter.Length; i++)
{
if (counter[i] % 2 == 1)
numRemove++;
}
return numRemove;