Maximize ones with limited flips
PayPalMachine Learning Engineer · OnsiteLast updated
This question evaluates proficiency with array algorithms, particularly sliding-window and two-pointer reasoning, complexity analysis, and the ability to adapt solutions for streaming data.
Given a binary array and an integer k, return the length of the longest contiguous subarray achievable by flipping at most k zeros to ones. Explain an efficient algorithm, its complexity, and how you would adapt it for a stream.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.