Skip to content

Commit 1eec20b

Browse files
authored
Create Minimum Moves to Convert String.java
1 parent 2392874 commit 1eec20b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int minimumMoves(String s) {
3+
int numOfMoves = 0;
4+
int idx = 0;
5+
while (idx < s.length()) {
6+
if (s.charAt(idx) == 'X') {
7+
idx += 2;
8+
numOfMoves++;
9+
}
10+
idx++;
11+
}
12+
return numOfMoves;
13+
}
14+
}

0 commit comments

Comments
 (0)