LeetCode #266 - Palindrome Permutation (JavaScript)

A very straightforward solution would be using Set. Other possible solution is using bitset.

const canPermutePalindrome = s => {
    const repeats = new Set();
    
    for (const c of s) {
        if (repeats.has(c)) {
            repeats.delete(c);
        } else {
            repeats.add(c);
        }
    }
    
    return repeats.size <= 1;
}