Increasing decreasing

unable to pass two test case please help

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”); } }

@Yuvraj_Luhach,
Wrong answer for input:
5
9 5 2 7 10
Correct Answer: true
Your answer: false

1 Like

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.