Skip to content

Commit 63237e6

Browse files
committed
Time: 149 ms (100.00%), Space: 37 MB (100.00%) - LeetHub
1 parent 61d3f16 commit 63237e6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
fun minOperations(s: String): Int {
3+
var even = 0
4+
var odd = 0
5+
6+
for (i in s.indices) {
7+
val char = s[i]
8+
if ((char == '0') == (i % 2 == 0))
9+
++even
10+
else
11+
++odd
12+
}
13+
14+
return minOf(even, odd)
15+
}
16+
}

0 commit comments

Comments
 (0)