# PROBLEM LINK:

Author: Ritesh Gupta

Tester: Abhishek Chaudhary

Editorialist: Ayush Shukla

# DIFFICULTY:

Calkwalk

# PREREQUISITES:

NONE

# PROBLEM:

You have to choose the minimum length of sub array such that the sum of that sub array is maximum possible. It is given that all the element are greater than equal to zero.

# EXPLANATION:

Since all the number are positive the minimum length sub array such that the sum of that sub array is maximum is the array starting from the leftmost positive element greater than 0 and ending at the rightmost positive element greater than 0.

If all the elements of the array are 0 then we will choose a sub array of length 1 as the maximum possible sum is 0.

# SOLUTIONS:

## Setter's Solution

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {

ll t;

cin>>t;

while(tâ€“){

ll n;

cin>>n;

ll a[n];

for(ll i=0;i<n;i++)cin>>a[i];

ll low = 0,high = n-1;

```
while(low<n&&a[low]==0)low++;
while(high>=0&&a[high]==0)high--;
if(low<high)cout<<high-low+1<<"\n";
else cout<<"1\n";
}
return 0;
```

}