Skip to content

Commit 7251c1c

Browse files
authored
Create L1446.go
1 parent d0a43b4 commit 7251c1c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Easy/L1446.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package Easy
2+
3+
func maxPower(s string) int {
4+
if len(s) == 0 {
5+
return 0
6+
}
7+
8+
cnt, ans := 1, 1
9+
for i := 1; i < len(s); i++ {
10+
if s[i] == s[i-1] {
11+
cnt++
12+
if cnt > ans {
13+
ans = cnt
14+
}
15+
} else {
16+
cnt = 1
17+
}
18+
}
19+
20+
return ans
21+
}

0 commit comments

Comments
 (0)