Test case failed?

why my one test case is getting failed ?

your code seems great. It does not cover one case i.e. when two consecutive numbers are same in the sequence. For example if your test case is like :

5
2
2
2
3
4

Then the output should be false. But your code returns true ! So kindly cover that case as well.

I hope this resolves your doubt !
Happy Coding :slight_smile:

import java.util.*;
public class Main {
public static void main(String args[]) {

	 Scanner scan = new Scanner(System.in);
        
        int n =scan.nextInt();
        int n1=scan.nextInt();
		int i=2;
        boolean isdec= true;
		while(i <= n)	
        {
            int n2 = scan.nextInt();
            if(n2>n1)
            {
            	isdec=false;
            }
            if(n2<n1 && isdec != true)
            {
                System.out.println(false);
                return;
            }
            if(n1==n2)
            {
            	System.out.println(false);
            }
            n1=n2;
            i++;
		}
		System.out.println(true);

}

}

where am i going wrong in this ?

 if(n1==n2)
{
        System.out.println(false);
        break;
}

break if the numbers are equal

test case is still getting failed


this is your corrected code and it passes all the test cases