Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool checkZeroOnes(string s) {
- int max1, max0, c1, c0;
- max1 = max0 = c1 = c0 = 0;
- for(char c: s){
- if(c=='0'){
- c0++;
- max1 = max(max1, c1);
- c1 = 0;
- }
- else{
- c1++;
- max0 = max(max0, c0);
- c0=0;
- }
- }
- max1 = max(max1, c1);
- max0 = max(max0, c0);
- if(max1 > max0) return true;
- return false;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement