Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Jan 13, 2024
1 parent 4bfbe28 commit cba49a6
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram

package main

import (
"fmt"
)

func minSteps(s string, t string) int {
cnt := make([]int, 26)
for i := 0; i < len(s); i++ {
cnt[s[i]-'a']++
cnt[t[i]-'a']--
}

result := 0
for i := 0; i < 26; i++ {
if cnt[i] > 0 {
result += cnt[i]
}
}

return result
}

func main() {
s := "leetcode"
t := "practice"

fmt.Println(minSteps(s, t))
}

0 comments on commit cba49a6

Please sign in to comment.