cielseven's picture
add 19 shard00 problems, update the algorithms, drop prim_forward_star
3805fe5
|
Raw History Blame Contribute Delete
914 Bytes

LeetCode 300: Longest Increasing Subsequence

Abstract model

A subsequence retains the relative order of selected elements but need not be contiguous. Among all subsequences whose values are strictly increasing, maximize the number of selected elements. The verification case uses the $O(n^2)$ DP in which dp[i] is the best length ending at index $i$.

Problem statement

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

Constraints

  • Original problem: $1 \le n \le 2500$ and $-10^4 \le nums_i \le 10^4$.
  • Verification case: $1 \le n \le 10^5$.

The function declares dp[100000] locally and uses its first $n$ cells. Its public inputs are nums and numsSize; the DP table is described only by the internal annotations.

Source

LeetCode 300, "Longest Increasing Subsequence".