Given a sequence of integers ( +ve and/or -ve) $A_1, A_2, \ldots, A_n$, I need to find the smallest subsequence $A_i,\ldots, A_j$ whose sum is at least M.
How would the algorithm for the same go if I need a complexity of $O(n\log n)$ or at-most $O(n)$?