728x90
const LIS = function (arr) {
let dp = Array.from({length: arr.length}).fill(1);
for(let i=1;i<arr.length;i++) {
for(let j=0;j<i;j++) {
if(arr[i]>arr[j] && dp[i]<dp[j]+1) dp[i] = dp[j]+1;
}
}
return Math.max(...dp);
};반응형
'BEB > algorithm' 카테고리의 다른 글
| 37_coinChange (0) | 2022.12.15 |
|---|---|
| 34_LCS (Longest Common Subsequence) (0) | 2022.12.12 |
| 백준6549 javascript 히스토그램, 32_largestRectangularArea (0) | 2022.12.08 |
| 29 binary heap 최대힙 (1) | 2022.12.05 |
| 27 gossipprotocol (0) | 2022.12.01 |
댓글