Longest Decreasing Subsequence
InterviewTime limit1sMemory limit256 MB
Find the length of the longest strictly decreasing subsequence of the given sequence.
- Level
Easy3 of 10
- Topics
- Dynamic programming
- Solved
- No attempts yet
Problem
A sequence is given. Write a program that finds the length of the longest decreasing subsequence of .
A subsequence is formed by picking one or more elements of and keeping their original order. A decreasing subsequence is one in which every element is strictly greater than the element right after it.
For example, if , the longest decreasing subsequence is and its length is 3.
Input
The first line contains the size of the sequence ().
The second line contains separated by spaces ().
Output
Print the length of the longest decreasing subsequence of on the first line.