Created
January 17, 2018 21:22
-
-
Save mayashavin/ea6072550a9f01f54d94b9b1d5646518 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
function isPermutation(strA, strB){ | |
var isValid = true; | |
//First validity check | |
if (!strA || !strB || strA.length !== strB.length){ | |
return !isValid; | |
} | |
var sortedA = sort(strA), sortedB = sort(strB); | |
return sortedA === sortedB; | |
} | |
function sort(str){ | |
return str.split("").sort().toString();; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment