unable to pass two test case please help
Increasing decreasing
import java.util.*; public class Main { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(), a = in.nextInt(); boolean b1 = true; int c = in.nextInt(); if (c >= a) { for (int i = 0; i < n - 2; i++) { a = c; c = in.nextInt(); if (a >= c) b1 = false; } } else if (c <= a) { for (int i = 0; i < n - 2; i++) { a = c; c = in.nextInt(); if (a <= c) b1 = false; } } if (b1 == false) System.out.println(“false”); else System.out.println(“true”); } }
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.