We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d0f005 commit e2ecdb5Copy full SHA for e2ecdb5
이용훈/10주차/260305.js
@@ -0,0 +1,18 @@
1
+/**
2
+ * @param {string} s
3
+ * @return {number}
4
+ */
5
+var minOperations = function(s) {
6
+ let mismatchStartWith0 = 0;
7
+ let mismatchStartWith1 = 0;
8
+
9
+ for (let i = 0; i < s.length; i++) {
10
+ const expected0 = (i % 2 === 0) ? '0' : '1';
11
+ const expected1 = (i % 2 === 0) ? '1' : '0';
12
13
+ if (s[i] !== expected0) mismatchStartWith0++;
14
+ if (s[i] !== expected1) mismatchStartWith1++;
15
+ }
16
17
+ return Math.min(mismatchStartWith0, mismatchStartWith1);
18
+};
0 commit comments