Skip to content

Commit a6b24ac

Browse files
authored
Create 300-Longest-Increasing-Subsequence.js
1 parent ca671eb commit a6b24ac

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var lengthOfLIS = function(nums) {
2+
let arr = Array(nums.length).fill(1);
3+
4+
for(let i = 1; i < arr.length; i++) {
5+
for (let j = 0; j < i; j++) {
6+
if (nums[i] > nums[j]) {
7+
arr[i] = Math.max(arr[i], arr[j] + 1);
8+
}
9+
}
10+
}
11+
return Math.max(...arr);
12+
};

0 commit comments

Comments
 (0)