We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23c8357 commit c0974d3Copy full SHA for c0974d3
Algorithm/evenarray.cpp
@@ -0,0 +1,27 @@
1
+#include <iostream>
2
+#include <vector>
3
+using namespace std;
4
+int t,s,e,i;
5
+vector<int>v;
6
+int main()
7
+{ cin>>t;
8
+ while(t--)
9
+ {
10
+ int a=0;
11
+ int b=0;
12
+ cin>>s;
13
+ for(i=0;i<s;i++)
14
15
+ cin>>e;
16
+
17
+ if((e%2)==0&(i%2)!=0)
18
+ {a+=1;}
19
+ if((e%2)!=0&(i%2)==0)
20
+ {b+=1;}
21
+ }
22
+ if(a==b)
23
+ {cout<<a<<"\n";}
24
+ else
25
+ {cout<<-1<<"\n";}
26
27
+}
0 commit comments