- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1869.java
27 lines (26 loc) · 809 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
packagecom.fishercoder.solutions.secondthousand;
publicclass_1869 {
publicstaticclassSolution1 {
publicbooleancheckZeroOnes(Strings) {
intzeroes = 0;
intones = 0;
for (inti = 0; i < s.length(); ) {
intstart = 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);
}
}
returnones > zeroes;
}
}
}