Created
December 15, 2022 23:31
-
-
Save abdulrahmanAlotaibi/a7068a270d94a493aaf8294af0991375 to your computer and use it in GitHub Desktop.
Valid Anagram
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
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