bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 300. Longest Increasing Subsequence

300. Longest Increasing Subsequence

Leetcode Solutions

Approach: Improve With Binary Search

  1. Initialize an empty array sub.
  2. Iterate over each number in nums. a. If sub is empty or the current number is greater than the last element in sub, append the number to sub. b. Otherwise, use binary search to find the first element in sub that is not smaller than the current number and replace that element with the current number.
  3. The length of the array sub is the length of the longest increasing subsequence.
UML Thumbnail

Approach: Dynamic Programming

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...