Reference no: EM132355786
Question :
Longest sorted subsequence. Write a function longest_monot one ( ) that returns the length and starting index of the longest contiguous sorted subsequence of a given list a. The subsequence can be in either ascending or descending order.
For example, given input [ 0, 10, 5, -1, 3, 6 your function should return (3, 1) , since the longest sorted (in this case, descending) subsequence is 10, 5, -1. For input [ -1, -5, -1, 0, 5 you should return (4, 1) (corresponding to the ascending subsequence -5, -1, 0, 5).
You can assume that there are no consecutive equal values in the sequence.