Skip to content

Instantly share code, notes, and snippets.

@imsarvesh
Created January 10, 2019 13:33
Show Gist options
  • Save imsarvesh/5347bdf9a3989f55b08d52723e57ec4e to your computer and use it in GitHub Desktop.
Save imsarvesh/5347bdf9a3989f55b08d52723e57ec4e to your computer and use it in GitHub Desktop.
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