Question
Given an unsorted array of integers, find the length of longest increasing subsequence.
Example:
|
|
Note:
- There may be more than one LIS combination, it is only necessary for you to return the length.
- Your algorithm should run in O(n2) complexity.
Follow up: Could you improve it to O(n log n) time complexity?
Answer
|
|
Time complexity: $O(n^2)$
corner case: nums:[] or nums:[1]
|
Time complexity: $O(n\log n)$