Test Case2 is wrong and
Showing Wrong Output
But the code is right as taught.
#include
using namespace std;
bool isSorted(int *a,int n)
{
if(n==1)
{
return true;
}
else if(a[0]<a[1] && isSorted(a+1,n-1))
{
return true;
}
else{
return false;
}
}
int main() {
int n;
cin>>n;
int *arr=new int[n];
for(int i=0;i<n;i++)
{
arr[i];
}
if(isSorted(arr,n)==true)
{
cout<<“true”;
}
else{
cout<<“false”;
}
}