[leetcode 300] Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. 풀이: -lower bound 사용 - dp는 가장 긴 수열을 저장하는 배열이다. (오름차순) - nums[i]를 dp의 마지막 숫자와 비교해서 nums[i]가 크면 dp에 집어 넣는다. - 작다면 dp배열에서 nums[i] 이상의 숫자의 위치를 찾는다. -> lower bound 사용 lower_boun..
2020. 10. 8.