题目:原题链接(中等)
标签:字符串
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
---|---|---|---|
Ans 1 (Python) | 60ms (95.83%) | ||
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一(统计变换的数量):
class Solution:
def minFlips(self, target: str) -> int:
ans = 0
now = "0"
for ch in target:
if ch != now:
now = ch
ans += 1
return ans