TypeScript Palindrome Rearranging
function palindromeRearranging(inputString: string): boolean {
const counts = new Map<string, number>();
for (const ch of inputString) {
counts.set(ch, (counts.get(ch) ?? 0) + 1);
}
let c = 0;
for (const v of counts.values()) {
if (v % 2 !== 0) {
c++;
}
}
return c <= 1;
}
This counts character frequency and checks whether the string has the right number of odd counts to form a palindrome.