Javscript with hashmap and Object.values()


  • 0
    W
    const canPermutePalindrome = s => {
      let map = {}
    
      for (let i = 0; i < s.length; i++) {
        let item = s[i]
    
        map[item] = ~~map[item] + 1
      }
    
      return Object.values(map).filter(e => e & 1).length <= 1
    }
    
    

Log in to reply
 

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