-
Notifications
You must be signed in to change notification settings - Fork 0
/
871_Div4_B.cpp
40 lines (31 loc) · 860 Bytes
/
871_Div4_B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<bits/stdc++.h>
using namespace std;
int longestBlankSpace(vector<int>& arr) {
int longestSpace = 0;
int currentSpace = 0;
for (int i = 0; i < arr.size(); i++) {
if (arr[i] == 0) {
currentSpace++;
} else {
longestSpace = max(longestSpace, currentSpace);
currentSpace = 0;
}
}
longestSpace = max(longestSpace, currentSpace);
return longestSpace;
}
int main() {
int t;
cin >> t; // number of test cases
while (t--) {
int n;
cin >> n; // length of the array
vector<int> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i]; // input array elements
}
int longestSpace = longestBlankSpace(arr);
cout << longestSpace << endl;
}
return 0;
}