1134. Longest Increasing Subsequence Length (Basic)

EasyDynamic ProgrammingLIS Family1D DP

Given an array nums, return the length of the longest strictly increasing subsequence, using the basic O(n^2) dynamic programming approach. The input is JSON {nums}.

Input: JSON {nums}.

Output: Integer — the length of the longest increasing subsequence.

Examples

Example 1
Input: {"nums":[10,9,2,5,3,7,101,18]}
Output: 4
Explanation: [2,3,7,18] has length 4.
Example 2
Input: {"nums":[7,7,7]}
Output: 1
Explanation: No strict increase.
Example 3
Input: {"nums":[0,1,0,3,2,3]}
Output: 4
Explanation: [0,1,2,3] has length 4.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →