(nums, tabu)
| 17 | const initTabu = (nums) => new Array(nums.length).fill(1); |
| 18 | |
| 19 | var linearSearch = (nums, tabu) => { |
| 20 | for (let right = 1; right < nums.length; right++) { |
| 21 | /* Time O(N) */ |
| 22 | for (let left = 0; left < right; left++) { |
| 23 | /* Time O(N) */ |
| 24 | const canUpdate = nums[left] < nums[right]; |
| 25 | if (!canUpdate) continue; |
| 26 | |
| 27 | const [_left, _right] = [tabu[left] + 1, tabu[right]]; |
| 28 | tabu[right] = Math.max(_right, _left); /* Space O(N) */ |
| 29 | } |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | /** |
| 34 | * Array - Subsequence |