package leetcode;

/**
 * https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros/
 */
public class Problem1869 {
    public boolean checkZeroOnes(String s) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1869 prob = new Problem1869();
        System.out.println(prob.checkZeroOnes("1101")); // true
        System.out.println(prob.checkZeroOnes("111000")); // false
        System.out.println(prob.checkZeroOnes("110100010")); // false
    }
}

@@ -184,336 +184,992 @@
     
-// TODO%0A        return false
+int maxZeroCount = 0;%0A        int tmpZeroCount = 0
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1869 prob = new Problem1869();%0A        System.out.println(prob.checkZeroOnes(%221101%22)); // true%0A        System.out.println(prob.checkZeroOnes(%22111000%22)); // false%0A        System.out.println(prob.checkZeroOnes(%22110100010%22)); // false
+int maxOneCount = 0;%0A        int tmpOneCount = 0;%0A        if (s.charAt(0) == '0') %7B%0A            tmpZeroCount = 1;%0A        %7D else %7B%0A            tmpOneCount = 1;%0A        %7D%0A        for (int i = 0; i %3C s.length() - 1; i++) %7B%0A            if (s.charAt(i) != s.charAt(i + 1)) %7B%0A                if (s.charAt(i + 1) == '0') %7B%0A                    tmpZeroCount = 1;%0A                %7D else %7B%0A                    tmpOneCount = 1;%0A                %7D%0A            %7D else %7B%0A                if (s.charAt(i) == '0') %7B%0A                    tmpZeroCount++;%0A                %7D else %7B%0A                    tmpOneCount++;%0A                %7D%0A            %7D%0A            maxZeroCount = Math.max(maxZeroCount, tmpZeroCount);%0A            maxOneCount = Math.max(maxOneCount, tmpOneCount);%0A        %7D%0A        maxZeroCount = Math.max(maxZeroCount, tmpZeroCount);%0A        maxOneCount = Math.max(maxOneCount, tmpOneCount);%0A        return maxOneCount %3E maxZeroCount;
 %0A   

Solve problem 1869