/*public class Solution {
public int solve(ArrayList<Integer> A) {
}
}
*/
/*Given an array A, check if it is sorted in non-decreasing order or not.
Non-decreasing order means that the numbers in a sequence can stay the same or increase,
but they cannot decrease. */
import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in) ;
int size = scn.nextInt();
// System.out.println("PTL Please enter the size of array"+size );
ArrayList<Integer> a = new ArrayList<>();
//System.out.println("Please enter array elements");
for (int i=0; i<size ; i++){
a.add(scn.nextInt());
}
boolean isNonDereasing = solve(a);
System.out.println(isNonDereasing ? "1" :"0" );
}
public static boolean solve(ArrayList<Integer> a) {
int n= a.size();
for (int i=0; i<n-1 ; i++)
{if (a.get(i)> a.get(i+1))
return false ;
}
return true ;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: