Share my JavaScript code runtime beat 100% javascript


  • 2
    M

    var canPermutePalindrome = function(s) {
    // implement hashset in javascript

    var set = {};
    for (var i = 0; i < s.length; i++) {
        if (!(s.charAt(i) in set)) {
            set[s.charAt(i)] = true;
        } else {
            delete set[s.charAt(i)];
        }
    }
    return Object.keys(set).length === 0 || Object.keys(set).length === 1;
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.