Sorted array(recursion)

#include
using namespace std;
bool sorted(int a[],int n){
if(n==1){
return true;
}
if(a[0]<a[1] && sorted(a+1,n-1))
{
return true;
}

return false;

}
int main(){
int n;
cin>>n;
int *a=new int[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
if(sorted(a,n))
{
cout<<“true”;
}
else
cout<<“false”;
}
why it is not passing all test cases?

Hi @tishya_goyal

Change the data type to long long int as input is upto 10^9. Also check for a[0]<=a[1] as array is not strictly increasing .
Hope it Helps.

1 Like

Link : https://ide.codingblocks.com/s/213234

1 Like

its still not passing 1 test case

I just submitted it again, it is passing all the test cases. Make sure you are not making an error in copy pasting.