Max Series of 1s
ARRAY
Problem
Given a binary array nums
and an integer k
, identify the start and end indices of the longest continuous series of 1s possible after flipping at most k
zeroes. If multiple solutions exist, prioritize the one with the lowest starting index.
Examples
findMaxConsecutiveOnes([1, 0, 1, 1, 0, 1, 0, 1, 0, 1], 2) // returns [0, 5] // By flipping the 0s at indices 1 and 4 // the longest continuous series of 1s from index 0 to 5 is achieved
Loading...
Loading...Loading...