oddCount
to 0 to track the number of characters with odd frequencies.oddCount
.oddCount
is greater than 1, return false
as more than one character has an odd frequency, which is not allowed in a palindrome.oddCount
is 0 or 1, return true
as the string can be permuted to form a palindrome.