Use table and toggle int values to speed up

  • 0

    We only need to toggle 1 and 0 to indicate odd or even in a 256 long list.

    class Solution(object):
    def canPermutePalindrome(self, s):
        for c in s:
            letterCounts[ic]=0 if letterCounts[ic] else 1
        return sum(letterCounts)<=1

Log in to reply

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