PIXELBANKv8.2.1
Menu

Longest Increasing Subsequence

Given an integer array nums, return the length of the longest strictly increasing subsequence.

A subsequence is derived from the array by deleting some or no elements without changing the order of the remaining elements.

Example:

Input:
10,9,2,5,3,7,101,18
Output:
4
Reasoning:
  • The input array is 10, 9, 2, 5, 3, 7, 101, 18, and we need to find the longest strictly increasing subsequence.
  • We can start by identifying potential increasing subsequences, such as 2, 5, 7, 101 or 2, 3, 7, 101 or 2, 5, 7, 18.
  • The longest increasing subsequence in the array is 2, 5, 7, 101 or 2, 3, 7, 101 with a length of 44.
  • The final output is the length of the longest increasing subsequence, which is 44.

Constraints:

  • 1 <= len(nums) <= 2500
  • -10^4 <= nums[i] <= 10^4
Editor

Test Results

0/0
Run code to see test results.