add new solutions
This commit is contained in:
parent
59b71480d4
commit
71189b61cf
8 changed files with 200 additions and 0 deletions
21
solutions/2/q242/solution.go
Normal file
21
solutions/2/q242/solution.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package q242
|
||||
|
||||
func isAnagram(s string, t string) bool {
|
||||
if len(s) != len(t) {
|
||||
return false
|
||||
}
|
||||
cnt := map[rune]int{}
|
||||
|
||||
for _, r := range s {
|
||||
cnt[r]++
|
||||
}
|
||||
for _, r := range t {
|
||||
cnt[r]--
|
||||
if cnt[r] < 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
var _ = isAnagram
|
||||
Loading…
Add table
Add a link
Reference in a new issue