The Problem is Simple. You are taking a list of strings as input but trying to compare them as numbers.
Even in Python strings can also be compared the same way as numbers, it doesn’t mean the comparison between numbers and their equivalent string expressions will be the same.
Simply, even your code runs successfully, your submission won’t be accepted. You have to convert the strings of the list to numbers first before comparing them.
And again, Please remove the link of the accepted solution you have posted here. Although not punishable, it is usually discouraged by the moderators of Toph.
This is another poorly defined problem. It should ask to check for either strictly ascending or non-descending values. “Ascending” can mean either of these two things. Or perhaps it is asking for something else? Should [1,1,1,1,1,1,1,1] be considered “ascending”?
Scanner inpu=new Scanner(System.in);
int N;
int count=0;
N=inpu.nextInt();
int array[]=new int[N];
for (int i = 0; i <N; i++) {
array[i]=inpu.nextInt();
}
for (int i = 0; i <N-1; i++) {
if(array[i]<=array[i+1]){
count++;
}
}
if(count==N-1){
System.out.print("yes");
}else{
System.out.print("No");
}