


ARR = [0, 1, 1, 0, 0, 1, 1, 1], here you can see the maximum length of consecutive 1’s is 3. Hence the answer is 3.
The first input line contains a single integer ‘T’, representing the number of test cases.
The first line of each test case contains a single integer ‘N’, representing the array's length.
The second line of each test case contains N space-separated integers representing the elements of the array.
For each test case, print a single integer representing the maximum length of consecutive 1’s in the array.
Output for each test case will be printed on a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
Approach:
In this approach, we will iterate over all the possible subarrays of the array starting at each index. If we find an 0 in the subarray we will stop as we have reached the maximum possible consecutive 1’s starting from i'th index, then we will check all the subarrays starting from the next index.
Algorithm:
Approach:
In this approach, we will iterate through the entire array and count the number of 1’s we have found. Each time we see a 0, we will reset the count. We can keep track of the maximum value for count through the entire iteration, and that will be the answer.
Algorithm: