In this article, we have explored algorithms to Find the longest sequence of consecutive ones when atmost k zeros can be altered to 1. This involve techniques like Sliding Window approach.
Table of Contents1) Problem statement2) Naive approach3) Sliding Window approach4) Conclusion1)Problem statement
Given a binary array. Find the longest sequence of consecutive ones when atmost k zeros can be altered to 1.
For example,
Let the binary array be nums=[1,0,1,1,0,0,1,0].
Let k ...
Published on March 07, 2022 05:58