Skip to content

Commit 12352ed

Browse files
committed
Runtime: 9 ms (Top 72.82%) | Memory: 46.7 MB (Top 65.16%)
1 parent 5929b8d commit 12352ed

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1+
// Runtime: 9 ms (Top 72.82%) | Memory: 46.7 MB (Top 65.16%)
2+
13
class Solution {
24
public int minFlips(String target) {
3-
5+
46
boolean lastBit = false;
5-
7+
68
int flips = 0;
79
for(int i=0;i<target.length();i++){
8-
10+
911
if(target.charAt(i)=='1' && !lastBit){
1012
flips++;
11-
lastBit = !lastBit;
13+
lastBit = !lastBit;
1214
}
1315
else if(target.charAt(i)=='0' && lastBit){
1416
flips++;
15-
lastBit = !lastBit;
17+
lastBit = !lastBit;
1618
}
17-
19+
1820
}
19-
21+
2022
return flips;
21-
22-
23+
2324
}
24-
}
25+
}

0 commit comments

Comments
 (0)