You are viewing a single comment's thread. Return to all comments →
CAN SOMEONE CORRECT IT import java.io.; import java.math.; import java.text.; import java.util.; import java.util.regex.*;
public class Solution {
public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t=sc.nextInt(); while(t>0) { int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } if(n==1) { System.out.println("YES"); } else { int l=0,c=0; for(int i=0;i<n-1;i++) { if(a[i]>a[i+1]) { l++; } else { c++; } } if(l==0||l==1) { System.out.println("YES"); } if(l>1) { System.out.println("NO"); } } t--; } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Impressing the Boss
You are viewing a single comment's thread. Return to all comments →
CAN SOMEONE CORRECT IT import java.io.; import java.math.; import java.text.; import java.util.; import java.util.regex.*;
public class Solution {
}