My issue
I have taken 2 counter variables for OM and ADDY as c1(current counter),omc(largest streak counter) for OM and c2,adc for ADDY.A loop is ran from 0 to n-1 indices of the matrices a[n],b[n], Checking if a[j] or b[j] is not zero then current counter is incremented. Similarly if a[j] or b[j] encounter zero then the current counter is reset to zero before which if current counter>largest streak counter then largest streak counter=current counter. At last largest counters are checked and printing is performed.
It is passing the sample test case but not the submission test cases please help me!!!
My code
#include <iostream>
using namespace std;
int main() {
int t,adc=0,omc=0;
cin>>t;
int n;
for(int i=0;i<t;i++){
cin>>n;
int a[n],b[n];
for(int j=0;j<n;j++) cin>>a[j];
for(int j=0;j<n;j++) cin>>b[j];
int c1=0;
omc=0; // OM counters
int c2=0;
adc=0; // ADDY counters
for(int j=0;j<n;j++){
if(a[j]!=0) c1++;
else if(a[j]==0){
if(omc<c1) omc=c1;
c1=0;
}
if(b[j]!=0) c2++;
else if(b[j]==0){
if(adc<c2) adc=c2;
c2=0;
}
}
if(adc>omc) cout<<"ADDY"<<endl;
else if(adc<omc) cout<<"OM"<<endl;
else cout<<"DRAW"<<endl;
}
return 0;
}
Learning course: Arrays using C++
Problem Link: CodeChef: Practical coding for everyone