New update is available. Click here to update.

Posted: 4 Jan, 2021

Difficulty: Easy

```
If you are given an array {1, 1, 0, 0, 1} then you will have to return the count of maximum one’s you can obtain by flipping anyone chosen sub-array at most once, so here you will clearly choose sub-array from the index 2 to 3 and then flip it's bits. So, the final array comes out to be {1, 1, 1, 1, 1} which contains five ones and so you will return 5.
```

```
The first line of input consists of a single integer T denoting the total number of the test case.
The first line of each test case contains an integer N, which represents the array's size.
The second line of each test case contains N space-separated integers representing the array elements accordingly.
```

```
For each test case, return a single integer representing the maximum number of 1's you can have in the array after at most one flip operation.
```

```
You don’t have to print anything; it has already been taken care of. Just implement the given function.
```

```
1 <= T = 100
1 <= N <= 10^4
0 <= ARR[i] <= 1
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Missing Number

Posted: 30 Oct, 2022

Difficulty: Easy

Longest Subarray With Zero Sum

Posted: 3 Nov, 2022

Difficulty: Moderate

Merge Two Sorted Arrays Without Extra Space

Posted: 19 Nov, 2022

Difficulty: Moderate

Ninja And The Strictly Increasing Array

Posted: 27 Nov, 2022

Difficulty: Moderate

Negative To The End

Posted: 16 Dec, 2022

Difficulty: Easy

Popular Interview Problems: