Last active
April 16, 2019 09:50
-
-
Save 4skinSkywalker/d750f523a78c1e175c517279c4c82656 to your computer and use it in GitHub Desktop.
Check if two strings are anagrams
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 anagrams(s1, s2) { | |
| if (s1.length !== s2.length) | |
| return false | |
| let fc1 = frequencyCounter(s1) | |
| let fc2 = frequencyCounter(s2) | |
| for (let key in fc1) | |
| if (!key in fc2 || fc1[key] !== fc2[key]) | |
| return false | |
| return true | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment