1649A Game codeforces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,t,i,l,r;
cin>>t;
while(t--)
{
int c=0,co=0;
cin>>n;
l=0;
r=n-1;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
if(a[i]==0&&c==0)
{
l=i-1;
c=1;
co=1;
}
}
for(i=n-1;i>0;i--)
{
if(a[i]==0)
{
r=i+1;
c=1;
co=1;
break;
}
}
if(co==0) cout<<"0"<<endl;
else cout<<r-l<<endl;
}
return 0;
}
0 Comments