Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* IMPORTANT: class must not be public. */
- import java.util.*;
- /*
- * uncomment this if you want to read input.
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- */
- class TestClass {
- public static boolean checkSorted(int arr[])
- {
- if(arr.length==1)
- {
- return true;
- }
- int newArr[]=new int[arr.length-1];
- for(int i=1;i<arr.length;i++)
- {
- newArr[i-1]=arr[i];
- }
- boolean ans= checkSorted(newArr);
- if(!ans)
- {
- return false;
- }
- if(arr[0]<=arr[1])
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public static void main(String args[] ) throws Exception {
- int size;
- Scanner sc=new Scanner(System.in);
- size=sc.nextInt();
- int arr[]=new int[size];
- for(int i=0;i<size;i++)
- {
- arr[i]=sc.nextInt();
- }
- System.out.println(checkSorted(arr));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement