We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f3230f5 commit d8fac4bCopy full SHA for d8fac4b
longest-increasing-subsequence/jinhyungrhee.java
@@ -0,0 +1,23 @@
1
+import java.util.*;
2
+class Solution {
3
+ public int lengthOfLIS(int[] nums) {
4
+
5
+ int[] dp = new int[nums.length];
6
+ Arrays.fill(dp, 1);
7
8
+ for (int i = 1 ; i < nums.length; i++) {
9
+ for (int j = i; j >= 0; j--) {
10
+ if (nums[j] < nums[i]) {
11
+ dp[i] = Math.max(dp[i], dp[j] + 1);
12
+ }
13
14
15
16
+ int maxVal = 0;
17
+ for (int num : dp) {
18
+ if (num > maxVal) maxVal = num;
19
20
21
+ return maxVal;
22
23
+}
0 commit comments