I need to return the number of LIS
of the array.
Pseudocode example:
if the arr is
int []arr = {2,4,90,-3,-2,-1,-10,-9,-8};
num of LIS is: 3
2,4,90
-3,-2,-1
-10,-9,-8
example 2:
arr [] = {2,-3,4,90,-2,-1,-10,-9,-8};
num of LIS is: 4
2,4,90
-3,4,90
-3,-2,-1
-10,-9,-8
I have tried to do this:
int [] A = {2,4,90,-3,-2,-1,-10,-9,-8};
int[] dp = new int[A.length];
for (int i = 0; i < A.length; i++) {
dp[i] = 1;
for (int j = 0; j <= i - 1; j++) {
if (A[j] < A[i]) {
dp[i] = dp[i] + dp[j];
}
}
System.out.println(dp[dp.length - 1] ) ;
}