My issue
Can someone give the logic for this question.
On what bases do we decided who has the maximum streak.
Problem Link: CS2023_STK Problem - CodeChef
Can someone give the logic for this question.
On what bases do we decided who has the maximum streak.
Problem Link: CS2023_STK Problem - CodeChef
@codestar05 - did you go through the sample input / output and explanation - maybe that will help you understand the logic.
//streak is the counting of days that a user visited /used a appiliction without a miss
//here they wants a maximum streak of a user .hope this explains it
include
using namespace std;
int count(int arr[],int n)
{int co,re;//co==count,re=final result
co=0; re=0;
for (int i=0;i<n;i++)
{
if (arr[i]==0)
{
if(re<co){
re=co;}//updating the maximum streak
co=0;//if any streak is missed i.e. 0 problems solved =>count resets
}
else
{
co++;
}
}
return re;//returig the maximum streak
}
int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int a[n],b[n];//arrays of om and addy
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
cin>>b[i];
}
int r,o;
r=count(a,n);
o=count(b,n);
if (r>o)
{
cout<<“Om\n”;
}
else if(o>r)
{
cout<<“Addy\n”;
}
else
{
cout<<“draw\n”;
}
}
return 0;
}
Thank you so much