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 12924f4 commit 938990fCopy full SHA for 938990f
longest-increasing-subsequence/hsskey.js
@@ -0,0 +1,16 @@
1
+/**
2
+ * @param {number[]} nums
3
+ * @return {number}
4
+ */
5
+var lengthOfLIS = function(nums) {
6
+ const lis = new Array(nums.length).fill(1);
7
+
8
+ for(let i = nums.length - 2; i >= 0; i--) {
9
+ for(let j = i + 1; j < nums.length; j++) {
10
+ if(nums[i] < nums[j]) {
11
+ lis[i] = Math.max(lis[i], 1 + lis[j])
12
+ }
13
14
15
+ return Math.max(...lis)
16
+};
0 commit comments