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, 2025
1 parent 7428ed3 commit 795ec4d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions leetcode/daily/3223/sol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// https://leetcode.com/problems/minimum-length-of-string-after-operations/description/

package main

import "fmt"

func minimumLength(s string) int {
freq := [26]int{}
for _, v := range s {
freq[v-'a']++
}

res := 0
for _, v := range freq {
if v > 0 {
if v&1 == 1 {
res += 1
} else {
res += 2
}
}
}

return res
}

func main() {
s := "aa"
fmt.Println(minimumLength(s))
}

0 comments on commit 795ec4d

Please sign in to comment.