category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

1004. Max Consecutive Ones III, Medium, 2 pointers

The atmost method

Approach
code ```cpp int longestOnes(vector& nums, int k) { int count = 0; int ans = 0; int l = 0; for (int r = 0; r < nums.size(); r++) { count += nums[r] == 0; while (count > k and l <= r) { count -= nums[l] == 0; l++; } ans = max(ans, r - l + 1); } return ans; } ``` </details>