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 036e221 commit e53c316Copy full SHA for e53c316
longest-increasing-subsequence/hyer0705.ts
@@ -0,0 +1,14 @@
1
+function lengthOfLIS(nums: number[]): number {
2
+ const n = nums.length;
3
+ const dp: number[] = Array(n).fill(1);
4
+
5
+ for (let i = 1; i < n; i++) {
6
+ for (let j = 0; j < i; j++) {
7
+ if (nums[j] < nums[i]) {
8
+ dp[i] = Math.max(dp[i], dp[j] + 1);
9
+ }
10
11
12
13
+ return Math.max(...dp);
14
+}
0 commit comments