@ jashwant raj,rahul
i think we have to sort array in non-decreasing order e.g. increasing order 1 way . 2,4,1,4,8,6,7,9 ----> 1,2,4,4,6,7,8,9 it will take max(nlogn) time with best sorting algo...& also if use counting sort it will take (n+k) time.... 2.way else in unsorted array it will take also o(logn) time to find if we use binary search in both cases then if we have to know k that is the length of sub- sequence so things is simple if length of subarray of length is 3 in above case is three then we have to find 3 element forming non-decreasing sub-array in array then sum them furture if its the case for sorted array it will take less time to find out max. in above case 3 max. is needed..so less time..O(1) constant time. in unsorted it will take atleast O(logn) time.... chk out solution. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.