#K69627. Maximum Jumps in a Sequence of Hills
Maximum Jumps in a Sequence of Hills
Maximum Jumps in a Sequence of Hills
You are given a sequence of hills represented as a list of integers, where each integer indicates the height of a hill. Your task is to determine the maximum number of jumps you can make, where each jump must go from one hill to a strictly taller hill.
In other words, you need to find the longest subsequence of hills such that every hill in the subsequence is strictly greater than the previous one. The answer is the number of jumps made (which is one less than the length of the subsequence), and if no jump is possible then the answer is 0.
Note: The formula for the answer when the longest increasing subsequence has length \(L\) is \(L-1\).
Example: For the input [1, 3, 2, 5, 4, 6], one possible longest increasing subsequence is [1, 3, 5, 6] which results in 3 jumps.
inputFormat
The first line of input contains an integer (n) representing the number of hills. The second line contains (n) space-separated integers representing the heights of the hills.
outputFormat
Output a single integer which is the maximum number of valid jumps.## sample
6
1 3 2 5 4 6
3