My issue
include
using namespace std;
void solve();
int main() {
int t;
cin>>t;
while(t–){
solve();
}
}
// your code goes here
void solve(){
int n;
cin>>n;
int A[n];
for(int i=0;i<n;i++){
cin>>A[i];
}
for(int i=0;i<n;i++){
if(A[i+1]<A[i]) {
cout<<“NO”;
return;
}
}
cout<<"YES";
}
this code giving output like this YESYESNONO which is correct for every test case which will enter in the code please someone help me with this how can I resolve it.
My code
#include <iostream>
using namespace std;
void solve();
int main() {
int t;
cin>>t;
while(t--){
solve();
}
}
// your code goes here
void solve(){
int n;
cin>>n;
int A[n];
for(int i=0;i<n;i++){
cin>>A[i];
}
for(int i=0;i<n;i++){
if(A[i+1]<A[i]) {
cout<<"NO";
return;
}
}
cout<<"YES";
}
Learning course: Arrays using C++
Problem Link: Difficulty Rating Order Practice Problem in - CodeChef