Skip to content

Commit e8f521c

Browse files
committed
solve: longest increasing subsequence
1 parent 7f57e00 commit e8f521c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

longest-increasing-subsequence/wogha95.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
var lengthOfLIS = function (nums) {
1212
// 각자 스스로는 최소 1의 lengthOfLIS를 가짐
1313
const longestLength = new Array(nums.length).fill(1);
14+
let result = 1;
1415

1516
// nums배열의 right까지 원소들 중 lengthOfLIS를 저장
1617
for (let right = 1; right < nums.length; right++) {
@@ -20,9 +21,10 @@ var lengthOfLIS = function (nums) {
2021
longestLength[right],
2122
longestLength[left] + 1
2223
);
24+
result = Math.max(result, longestLength[right]);
2325
}
2426
}
2527
}
2628

27-
return Math.max(...longestLength);
29+
return result;
2830
};

0 commit comments

Comments
 (0)