My code is failing the Test Case 1. I do not know what is that test case. But I have checked it passes for -ve numbers also. I am not able to get 100 in this challenge. Can you please point what is missing?
import java.util.Scanner;
public class SortedArray {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String sizeofArray = sc.nextLine();
String elementsofArray = sc.nextLine();
int[] array = new int[Integer.parseInt(sizeofArray)];
String[] result = elementsofArray.split("\\s");
for (int x=0; x<result.length; x++)
array[x] = Integer.parseInt(result[x]);
System.out.println(isArrayInIncreasingOrder(array,0));
}
static boolean isArrayInIncreasingOrder(int[] array, int selectedIndex) {
if(selectedIndex == array.length-1 ){
return true;
}
boolean result = true;
for( int x=selectedIndex; x<array.length-1; ++x){
if(array[x+1] > array[x])
{
boolean currentResult = isArrayInIncreasingOrder(array,x+1);
result = result && currentResult;
}
else
result = false;
if(!result)
break;
}
return result;
}
}