[1, 2, 3, 4] is a strictly increasing array, while [2, 1, 4, 3] is not.
The first line of input contains an integer 'N', representing the size of the array.
The second line of input contains 'N' space-separated integers, representing the elements of the array.
The only output line contains one integer representing the length of the longest increasing subsequence.
You do not need to print anything; it has already been taken care of. Just implement the given functions.
1 <= N <= 10^5
-10^5 <= element <= 10^5
Time Limit: 1sec
if (arr[curPosition] > prev)
{
taken = 1 + lisHelper(arr[curPosition], curPosition + 1);
}
int notTaken = lisHelper(prev,curPosition + 1);
//we can always skip the current element
if (curPosition==0 || arr[curPosition] > arr[prevPosition])
{
taken = 1 + longestIncreasingSubsequenceHelper(
curPosition, curPosition + 1);
}
//we can always skip the current element
int notTaken = longestIncreasingSubsequenceHelper(prevPosition, curPosition + 1);
//Now memoize it at
dp[prevPosition+1][curPosition] = max(taken, notTaken)
Merge Two Sorted Arrays Without Extra Space
Ninja And The Strictly Increasing Array
Negative To The End
8-Queen Problem
Find Duplicate in Array