mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
add: leetcode 1446 solution
This commit is contained in:
@ -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
|
||||
}
|
Reference in New Issue
Block a user