Skip to content

Commit 4b07d96

Browse files
authored
Create minimum-moves-to-convert-string.py
1 parent 497d449 commit 4b07d96

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def minimumMoves(self, s):
6+
"""
7+
:type s: str
8+
:rtype: int
9+
"""
10+
result = i = 0
11+
while i < len(s):
12+
if s[i] == 'X':
13+
result += 1
14+
i += 3
15+
else:
16+
i += 1
17+
return result

0 commit comments

Comments
 (0)