Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 47e01c8

Browse files
authoredJul 31, 2020
Create bulb-switcher-iv.py
1 parent c903d79 commit 47e01c8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎Python/bulb-switcher-iv.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def minFlips(self, target):
6+
"""
7+
:type target: str
8+
:rtype: int
9+
"""
10+
result, curr = 0, '0'
11+
for c in target:
12+
if c == curr:
13+
continue
14+
curr = c
15+
result += 1
16+
return result

0 commit comments

Comments
 (0)
Please sign in to comment.