Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Another way to look at it - Go

jarrett

Sep 18, 2025

Sort the characters in the two strings. If they're equal, they're anagrams.

func (sol *Solution) isAnagram(s, t string) bool {

bs := []byte(s)
bt := []byte(t)
slices.Sort([]byte(bs))
slices.Sort([]byte(bt))

if string(bs) == string(bt) {
   return true
}

return false

}

It's annoying that the version of Go on this site is ancient - 1.13.

0

0

Comments
Comments