Longer Contiguous Segments of Ones than Zeros Solution:- Approach:- Code:- public boolean checkZeroOnes(String s) { int countOne = 0; int countZero = 0; int maxOne=0; int maxZero = 0; for ( char m:s.toCharArray()) { if (m==’0′) { countZero ++; countOne=0; } if (m==’1′) { countOne ++; countZero=0; } maxOne = Math.max(maxOne,countOne); maxZero = Math.max(maxZero,countZero); }…
LeetCode 1869 Solution in Java
Posted on