Longest Increasing Subsequence

Medium Solved

Description

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

A subsequence is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements.

Input format / Clarification:

  • Line 1: JSON array of integers

Examples

Input:

[10,9,2,5,3,7,101,18]

Output: 4

Input:

[0,1,0,3,2,3]

Output: 4

Note:

Output should be a single integer representing the length of the longest increasing subsequence.

No submissions yet.

Discuss dynamic programming (O(n²)) vs binary search optimization (O(n log n)).

Test Cases