Algorithm · LinkedIn · Medium
Problem: Max Consecutive Ones II You are given a binary array nums whose entries are exclusively 0 or 1. You can change no more than one 0 into a 1. Find the greatest possible length of a contiguous run of 1s after making that optional change. Example Explanation: Changing the first 0 produces [1,1,1,1,0,1], so the longest run of 1s contains 4 elements. Follow-up: Streaming Data Suppose the values are delivered continuously and retaining the complete array is not possible.…