平台开发者/北京seo平台
题目:原题链接(简单)
标签:字符串
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
---|---|---|---|
Ans 1 (Python) | O(N)O(N)O(N) | O(1)O(1)O(1) | 52ms (76.53%) |
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一(双指针):
def maxPower(self, s: str) -> int:last = s[0]start = 0ans = 0for i in range(1, len(s)):if s[i] != last:ans = max(ans, i - start)last = s[i]start = ielse:ans = max(ans, len(s) - start)return ans