Skip to content

Instantly share code, notes, and snippets.

@abdulrahmanAlotaibi
Created December 15, 2022 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdulrahmanAlotaibi/a7068a270d94a493aaf8294af0991375 to your computer and use it in GitHub Desktop.
Save abdulrahmanAlotaibi/a7068a270d94a493aaf8294af0991375 to your computer and use it in GitHub Desktop.
Valid Anagram
func isAnagram(s string, t string) bool {
var message Text
json.Unmarshal(data, &message)
if len(s) != len(t) && len(t) > int(math.Pow(10, 4) * 5) || len(s) < 1 {
return false
}
for i := 0 ; i < len(s) ; i++{
isChExsist := false
for j:=0 ; j < len(t); j++ {
if string(s[i]) == string(t[j]){
s := strings.Split(t,"")
isChExsist=true
s = append(s[:j], s[j+1:]...)
t = strings.Join(s, "")
break
}
}
if !isChExsist {
return false
}
}
if len(s) != 0 && len(t) != 0 {
return false
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment