Skip to content

Commit

Permalink
Create monotone-increasing.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gabedonnan authored Jan 17, 2023
1 parent 4142337 commit 70fe85c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions monotone-increasing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution: #Credit to warrenruud for helping see the logic
def minFlipsMonoIncr(self, s: str) -> int:
temp = s.find("1")
temp_ones = 0
final = 0
if s == -1:
return 0

for num in s[temp:]:
if num == "1":
temp_ones += 1
elif temp_ones > 0:
temp_ones -= 1
final += 1
return final

0 comments on commit 70fe85c

Please sign in to comment.