Skip to content

Instantly share code, notes, and snippets.

@4skinSkywalker
Last active April 16, 2019 09:50
Show Gist options
  • Select an option

  • Save 4skinSkywalker/d750f523a78c1e175c517279c4c82656 to your computer and use it in GitHub Desktop.

Select an option

Save 4skinSkywalker/d750f523a78c1e175c517279c4c82656 to your computer and use it in GitHub Desktop.
Check if two strings are anagrams
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