My issue
int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=1;i<n;i++){
if(a[i-1]>a[i]){
cout<<"No"<<endl;
}
cout<<"YES"<<endl;
}
}
return 0;
}
getting this output
YES
YES
YES
YES
YES
YES
YES
No
YES
YES
YES
No
YES
No
YES
how to get output correct output this is showing comparison of every element present in an array.
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
if(a[n-1]>a[n]){
cout<<"No"<<endl;
}
cout<<"YES"<<endl;
}
return 0;
}
Learning course: Arrays using C++
Problem Link: CodeChef: Practical coding for everyone