题目
解法:
每次有连续的两个字符不同就需要一次反转
class Solution:def minFlips(self, target: str) -> int:if not target:return 0if target[0] == '0':count = 0else:count = 1for i in range(1,len(target)):if target[i]!=target[i-1]:#print(i)count += 1return count
每次有连续的两个字符不同就需要一次反转
class Solution:def minFlips(self, target: str) -> int:if not target:return 0if target[0] == '0':count = 0else:count = 1for i in range(1,len(target)):if target[i]!=target[i-1]:#print(i)count += 1return count