Question
The Loss-Maker’s Streak
Pulkit is a trader known more for his losses than his profits. He likes to invest in stocks that keep going down in value.
Given an integer array nums representing stock prices over n days, Pulkit wants to find the longest streak of days where each day's price is strictly lower than the previous day's.
In other words, find the length of the longest strictly decreasing subsequence of nums, representing the longest period his investments kept losing value.
Input
The first line of the input contains a single integer n, representing the size of the array nums.
The second line of the input contains n space separated integers representing elements of the array nums.
The second line of the input contains n space separated integers representing elements of the array nums.
Output
Return a single integer, the length of the longest strictly decreasing subsequence.
Example
Sample Input
8
2 3 4 3 2 8 1 0
Output
5
Explanation
Longest decreasing subsequence is of length 5. One such subsequence is: 4 3 2 1 0.
8
2 3 4 3 2 8 1 0
Output
5
Explanation
Longest decreasing subsequence is of length 5. One such subsequence is: 4 3 2 1 0.