forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_1869.java
27 lines (26 loc) · 794 Bytes
/
_1869.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.fishercoder.solutions;
public class _1869 {
public static class Solution1 {
public boolean checkZeroOnes(String s) {
int zeroes = 0;
int ones = 0;
for (int i = 0; i < s.length(); ) {
int start = i;
while (i < s.length() && s.charAt(i) == '0') {
i++;
}
if (i > start) {
zeroes = Math.max(zeroes, i - start);
}
start = i;
while (i < s.length() && s.charAt(i) == '1') {
i++;
}
if (i > start) {
ones = Math.max(ones, i - start);
}
}
return ones > zeroes;
}
}
}