Find any permutations is form the palindrome or not



Problem to find the any permutations string form palindrome or not.



Example-1:


Input    : n = "add"
Output   : True
Explain  : "dad" is a palindrome. 


Example-2:


Input    : n = "carrace"
Output   : True
Explain  : "racecar" is a palindrome.  


Example-3:


Input    : n = "car"
Output   : False







Solution




n = "add"

a = list(set(n))

b = "".join(a)

l = []

k = []

for i in range(len(b)):

    c = n.count(b[i])

    l.append(c)

for x in l:

    if(x % 2 == 1):

        k.append(x)

if(len(k) == 1 or len(k) == 0):

    print("True")

else:

    print("False")



Output



True