Suppose I have an array of {2, 5, 0}. I want to find all possible subsets of consecutive elements of this array. The result should be:
{2}, {5}, {0}, {2, 5}, {5, 0}, {2, 5, 0}
Note there is no {2, 0}.
I have found and thought of many solutions. However, most of them have a time complexity of O(n²) or O(2n). Is there an algorithm to solve this problem with a better time complexity, such as O(nlogn)?