New update is available. Click here to update.

Topics

The Road Department is planning to make some new traffic regulations. But to make the regulations they need to analyze the current situation of the traffic.

The traffic can be analyzed from an array * 'VEHICLE'* of length

Unfortunately the array ‘VEHICLE’ got corrupted as at most * 'M'* '1' got flipped to ‘0’.

Traffic jam is defined as the length of consecutive vehicles on the road.

The Road Department wants to know the worst possible scenario for the traffic jam. Return the maximum possible length of the consecutive vehicles.

```
Input: ‘N’ = 3, ‘M’ = 1, VEHICLE’ = [0, 1, 1]
Output: 3
Explanation:
As there is at most one 1 that got flipped to 0, so for the worst-case scenario we can reflip the first(1-based ) index to 1, resulting in a length of 3.
```

Detailed explanation

```
3 1
0 1 1
```

```
3
```

```
As there is at most one 1 that got flipped to 0, so for the worst-case scenario we can reflip the first index (1- based) to 1, resulting in a length of 3.
```

```
6 3
0 1 0 0 1 0
```

```
5
```

```
1 <= N <= 10^6
1 <= M <= N
0 <= VEHICLE[i] <= 1
Time Limit: 1 sec
```