Hi, I have just managed to find sorted subsequence of length 3 in an unsorted array.

I want to know how to do it to find subsequence of length k.

length of an array can be upto 100000.

Actual Question is : Given an unsorted array of n integers, find the 3 elements such that a[x] < a[y] < a[z] and x < y < z. I have done it in O(n) space and time complexity.

But I want to do it for k elements.