I came up with simple following recursive solution for Longest increasing sub-sequence. But, Can you help to include memoization into this recursive solution.
public int findLIS(int a[], int maxSoFar, int item, int count) {
if(item == a.length) {
return count;
}
int length1 = findLIS(a,maxSoFar, item+1, count);
int length2 = 0;
if(a[item] > maxSoFar) {
length2 = findLIS(a, a[item], item+1, count + 1);
}
return Math.max(length1, length2);
}
PS: This not a homework question, it is more of my interest.