Find the longest oscillating subsequence
Given the sequence of numbers find the longest oscillating subsequence
Solution
The oscillating sequence is the sequence, when the 2 adjacent numbers are either greater than or smaller than the current number. So, for example following is the oscillating sequence:
1, 7, 4, 6, 2
So, 7 is greater than both 1 and 4, 4 is less than both 4 and 6 and so on.
Now, given the sequence of number we have to find the longest oscillating subsequence.
[Read More]