Created
March 4, 2012 22:34
-
-
Save PirosB3/1975166 to your computer and use it in GitHub Desktop.
what would you tell me of this code?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Function is called with a string | |
def isAnagramOfPalindrome ( S ): | |
# Check length if length even then all need to be two | |
# if not even there must be a -1 | |
dic = {} | |
for c in S: | |
if dic.__contains__(c): | |
dic[c] += 1 | |
else: | |
dic[c] = 1 | |
# Check even or not | |
is_even = len(S) % 2 | |
odd = False | |
for el in dic: | |
if dic[el] %2 != 0: | |
if not is_even: | |
if not odd: | |
return 0 | |
else: | |
odd = True | |
return 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment