Why this code for longest increasing subsequence is not correct? This should be, right?
#include<bits/stdc++.h>
using namespace std;
int recursion(int arr[], int i, int j){
if(i==j){
return 1;
}
if(i>j){
return 0;
}
if(arr[i]<arr[j]){
return 2 + recursion(arr,i+1,j-1);
}
return max(recursion(arr,i+1,j), recursion(arr,i,j-1));
}
int main(){
int arr[] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15};
int n = sizeof(arr)/sizeof(int);
cout<<recursion(arr,0,n-1);
return 1;
}