Skip to content

Commit

Permalink
solve: longest increasing subsequence
Browse files Browse the repository at this point in the history
  • Loading branch information
wogha95 committed Sep 21, 2024
1 parent 7f57e00 commit e8f521c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion longest-increasing-subsequence/wogha95.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
var lengthOfLIS = function (nums) {
// 각자 스스로는 최소 1의 lengthOfLIS를 가짐
const longestLength = new Array(nums.length).fill(1);
let result = 1;

// nums배열의 right까지 원소들 중 lengthOfLIS를 저장
for (let right = 1; right < nums.length; right++) {
Expand All @@ -20,9 +21,10 @@ var lengthOfLIS = function (nums) {
longestLength[right],
longestLength[left] + 1
);
result = Math.max(result, longestLength[right]);
}
}
}

return Math.max(...longestLength);
return result;
};

0 comments on commit e8f521c

Please sign in to comment.