Max Consecutive Ones III - C++ Solution @ LeetCode
Max Consecutive Ones III, is a LeetCode problem. In this post we will see how we can solve this challenge in C++
Given an array A of 0s and 1s, we may change up to K values from 0 to 1.
Return the length of the longest (contiguous) subarray that contains only 1s.
Input: A = [1,1,1,0,0,0,1,1,1,1,0], K = 2 Output: 6 Explanation: [1,1,1,0,0,1,1,1,1,1,1] Bolded numbers were flipped from 0 to 1. The longest subarray is underlined.
Input: A = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1, ....
You can find the full details of the problem Max Consecutive Ones III at LeetCode
Solution: Please check the main.cpp snippet for the solution.
This solution originally posted at: Github by @kamyu104