Back to course home
0% completed
Solution: Max Consecutive Ones III
Problem Statement
Given an array nums
containing 1
and 0
digits, return the maximum number of consecutive 1
s if you can flip at most any k
0
s.
Examples
-
Example 1:
- Input: nums =
[1, 0, 1, 1, 0, 0, 1, 1, 1, 0]
, k =2
- Expected Output:
7
- Justification: Flipping the two 0s in the middle section
[0, 0]
results in the longest continuous sequence of 1s:[1, 1, 1, 1, 1, 1, 1]
.
- Input: nums =
-
Example 2:
- Input: nums =
[0, 1, 1, 0, 1, 0, 1, 0, 1]
, k =1
- Expected Output:
4
- Input: nums =
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible