-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckSort.java
More file actions
35 lines (33 loc) · 847 Bytes
/
Copy pathCheckSort.java
File metadata and controls
35 lines (33 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.*;
public class CheckSort{
public static int check(int[] num ){
int n=num.length;
for(int i=0;i<n-1;i++){
if(num[i]>num[i+1])
return 0;
}
return 1;
}
public static int des(int[] num ){
int n=num.length;
for(int i=0;i<n-1;i++){
if(num[i]<num[i+1])
return 0;
}
return 1;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int[] num = new int[n];
for(int i=0;i<n;i++){
num[i]=sc.nextInt();
}
int finalans=check(num);
if(finalans==1){
System.out.println("YEs sorrted bhai ");
}else{
System.out.println("No bhai not sorted ");
}
}
}