Wednesday, September 5, 2012

Longest subsequence

Given an array A of integers such that #A = n, find the longest sequence such that i_j < i_{j+1} and A[i_j] <= A[i_{j+1}] for any j \in [1, k-1]