Skip to content

Commit 795ec4d

Browse files
committed
add sol
1 parent 7428ed3 commit 795ec4d

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

leetcode/daily/3223/sol.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// https://leetcode.com/problems/minimum-length-of-string-after-operations/description/
2+
3+
package main
4+
5+
import "fmt"
6+
7+
func minimumLength(s string) int {
8+
freq := [26]int{}
9+
for _, v := range s {
10+
freq[v-'a']++
11+
}
12+
13+
res := 0
14+
for _, v := range freq {
15+
if v > 0 {
16+
if v&1 == 1 {
17+
res += 1
18+
} else {
19+
res += 2
20+
}
21+
}
22+
}
23+
24+
return res
25+
}
26+
27+
func main() {
28+
s := "aa"
29+
fmt.Println(minimumLength(s))
30+
}

0 commit comments

Comments
 (0)