Created
January 10, 2019 13:33
-
-
Save imsarvesh/5347bdf9a3989f55b08d52723e57ec4e to your computer and use it in GitHub Desktop.
This file contains 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
var isAnyPermutationPalindrom = (str) => { | |
var charSet = new Set(); | |
for(var c of str.split('')){ | |
if(charSet.has(c)){ | |
charSet.delete(c) | |
} else { | |
charSet.add(c) | |
} | |
} | |
return charSet.size <= 1 | |
} | |
isAnyPermutationPalindrom('civic') //true | |
isAnyPermutationPalindrom('civil') //false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment