deno.land / x / masx200_leetcode_test@10.6.5 / longest-increasing-subsequence / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export default function lengthOfLIS(nums: number[]): number { const tails = Array.from(nums).fill(0); let res = 0;
for (const num of nums) { let i = 0; let j = res; while (i < j) { const m = Math.floor((i + j) / 2); if (tails[m] < num) { i = m + 1; } else { j = m; } } tails[i] = num; if (res === j) res++; } return res;}
masx200_leetcode_test

Version Info

Tagged at
a year ago