Maximize Number of 1's | Problem of the Day-01-08-21 | Riya Singhal

preview_player
Показать описание
Submit your solutions here:

Follow us on our Social Media Handles -

Also, Subscribe if you haven't already! :)
Рекомендации по теме
Комментарии
Автор

GFG badly needs to improve its teaching faculty 😒 Too lengthy and unimpressive videos ...Other Youtubers are way too good !!!

ambisingh
Автор

we don't even need count, we can directly work with m, like this :
class Solution{
public:

int findZeroes(int arr[], int n, int m) {
int l =0, r=0, res=0;
while(r < n){
if(arr[r++] == 0) m--;

while(m < 0){
if(arr[l++] == 0) m++;
}

res = max(res, r-l);
}
return res;
}
};

tanmaykumar
Автор

what if the input is 110110110000111, and m = 2

NihalSingh-lden