Descrtiption:
Solution:
We are gonna start from the last value of array.
ex)
nums = [1 ,2 ,4, 3]
LIS[3] = 1
LIS[2] = max(1, 1 + LIS[3]) = 1 (nums[2] > nums[3])
LIS[1] = max(1, 1 + LIS[2], 1 + LIS[3]) = 2
LIS[0] = max(1, 1+1, 1+1, 1+2) = 3
So, the answer is 3.
Time Complexity: O(n^2)
'LeetCode ๐๏ธ > Dynamic Programming' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
198. House Robber (0) | 2023.07.01 |
---|---|
377. Combination Sum IV (0) | 2023.06.30 |
139. Word Break (0) | 2023.06.29 |
332. Coin Change (0) | 2023.05.26 |
70. Climbing Stairs (0) | 2023.05.25 |