Python solution. Easy to understand.


  • 1
    K
        num=0
        for i in set(list(s)):
            num+=list(s).count(i)/2  #Count the number of duplicate letters.
        num=num*2
        if len(list(s))!=num:   #See if there could be one sole letter in the middle.
            num=num+1
        return num

Log in to reply
 

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