python solution. 38ms.(beats 99.91%) easy to understand


  • 0
            a = 0
            b = 0
            sett = set(s)
            while len(sett):
                c = s.count(sett.pop())
                if c%2 == 0:
                    a += c
                else:
                    a += c-1
                    b = 1
            return a + b
    

Log in to reply
 

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