add: leetcode 1446 solution

This commit is contained in:
tphyhFighting
2021-12-01 10:44:57 +08:00
parent a45992e7de
commit 84730fa795

View File

@ -0,0 +1,22 @@
package leetcode
func maxPower(s string) int {
cur := s[0]
cnt := 1
ans := 1
for i := 1; i < len(s); i++ {
if cur == s[i] {
cnt++
} else {
if cnt > ans {
ans = cnt
}
cur = s[i]
cnt = 1
}
}
if cnt > ans {
ans = cnt
}
return ans
}