vector<int> Solution::maxone(vector<int> &A, int B){ int l = 0, r = 0, n = A.size(), now = 0; int len = 0, p = 0; while(r < n) { while(r < n and now <= B) { if(r - l > len) { len = r - l; p = l; } if(A[r++] == 0) now += 1; } if(now <= B and r - l > len) { len = r - l; p = l; } while(r < n and now > B) { if(A[l++] == 0) now -= 1; } } vector<int> res; for(int i = p; i < p + len; i++) res.push_back(i); return res; }