Sorted Array challenge for Recursion question

I am unable to pass 1 test case ,
Here is my code

#include
using namespace std;
bool isSorted(long long int *a,int n)
{
if(n==1)
return true;
if(a[0]<a[1]&&isSorted(a+1,n-1))
{
return true;
}
return false;
}
int main() {
int N;
cin>>N;
long long int a[N];
for(int i=0;i<N;i++)
{
cin>>a[i];
}
if(isSorted(a,N)){
cout<<“true”;
}
else
cout<<“false”;
return 0;
}

@1706157,
Please provide a Coding Blocks IDE link of your code. Please make sure you compile before you save the code. And share the link of saved code here.

  • Correction: a[0 ]<= a[1]

In these type of question , I dont understand when to use lond int or long long int .
For example , In this question the constraint is
1 < N < 1000
-10^9 < i < 10^9,
so N will definitely be of int type but what about i , should it be int ,long int .
How do we determine it ?

@1706157,
Use long long if you feel unsure. You can also always use long long instead of int. Just appx. |(int)|<=1e9, else long long

okk, thanks for help :slightly_smiling_face:

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.