I was trying to solve the record breaker problem from google kickstart Round D 2020 I submitted the following code in C++:
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int testcase;
cin>>testcase;
int t=1;
while(t<=testcase){
int n;
cin>>n;
int arr[n+1];
for(int i=0;i<n;i++)
cin>>arr[i];
arr[n]=0;
int prev=0,ans=0;
for(int i=0;i<n;i++){
if(arr[i]>prev && arr[i]>arr[i+1]){
ans++;
}
prev=max(prev,arr[i]);
}
cout<<"Case #"<<t<<": "<<ans<<endl;
t++;
}
return 0;
}
It passed the sample test set and I also tried to check this on certain edge cases from different articles and websites but still unable to find the error as it is not passing the test set 1. Please help.