1182. Longest Decreasing Subsequence

MediumDynamic ProgrammingLIS Family

Given an array nums, return the length of the longest strictly decreasing subsequence. The input is JSON {nums}.

Input: JSON {nums}.

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

Examples

Example 1
Input: {"nums":[5,4,3,2,1]}
Output: 5
Explanation: The whole array decreases.
Example 2
Input: {"nums":[1,2,3]}
Output: 1
Explanation: No decrease.
Example 3
Input: {"nums":[9]}
Output: 1
Explanation: Single element.

Constraints

Asked by

AmazonMicrosoftGoogleAdobeFlipkart
Solve this problem in the editor →