Ai
1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
flip-string-to-monotone-increasing.py 311 Bytes
Copy Edit Raw Blame History
kamyu authored 2018-10-21 15:18 +08:00 . Create flip-string-to-monotone-increasing.py
# Time: O(n)
# Space: O(1)
class Solution(object):
def minFlipsMonoIncr(self, S):
"""
:type S: str
:rtype: int
"""
flip0, flip1 = 0, 0
for c in S:
flip0 += int(c == '1')
flip1 = min(flip0, flip1 + int(c == '0'))
return flip1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

Search