LOngest Palindrome


  • 0

    @howezz
    Since, your hash solution logic is a little bit faimliar I am tagging you in particular:-

    #print c.items()
            f=[]
            g=[]
            h=[]
            w=[]
            w=word[::-1]
            for i in word:
                if word.count(i)%2==0:
                    g.append(i)
                elif word.count(i)==1:
                    f.append(i)
                else:
                    h.append(i)
            print g
            print f
            print h
            if len(f)>0 and len(h)>1:   
                return len(g) + len(h)
            elif w==word:
                return len(word)
            elif len(f)>0:
                return len(g)+1
            else:
                return len(g)
    

    Apart from horrendous usage of loops. can you guide me a little on where I am failing on logic for half of my cases ?

    Thanks


Log in to reply
 

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