Covid Pandemic and Long Queue - COVIDLQ Code Chef Easy Question
Welcome back to my blog , today we will discuss this easy question.
Here is the link to the PROBLEM .
So , the problem is very simple , we just need to find whether there are two people at distance less than 6 feet .
Just find the first person and then find the next person and if the distance is less than 6 , then break the code and then print NO otherwise continue the code and finally print YES .
Please take a look at the following code :-
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
int x=1,count=6,j=0;
int i=0;
while(i!=n)
{
cin>>arr[i];
i++;
}
i=0;
while(arr[i]==0)
{
i++;
}
while(i!=n)
{
if(arr[i]==1)
{
if(count<6)
{
x=0;
break;
}
else
{count=0;}
}
count++;
i++;
}
if(x==0)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
}
}
// your code goes here
return 0;
}
For any doubts and queries , please write in the comments section .
Comments
Post a Comment