Go solution (0ms) using a byte array map


  • 0
    func canPermutePalindrome(s string) bool {
        oddFound := false
        charMap := [128]byte{}
        for i := 0; i < len(s); i++ {
            charMap[s[i]]++
        }
        for i := 0; i < len(charMap); i++ {
            if charMap[i] % 2 != 0 {
                if oddFound { return false }
                oddFound = true
            }
        }
        return true
    }
    

Log in to reply
 

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