Google Interview: Find all contiguous subsequence in a given array of integers, whose sum falls in the given range. Can we do better than O(n^2)?
问题 Given an array of Integers, and a range (low, high), find all contiguous subsequence in the array which have sum in the range. Is there a solution better than O(n^2)? I tried a lot but couldn't find a solution that does better than O(n^2). Please help me find a better solution or confirm that this is the best we can do. This is what I have right now, I'm assuming the range to be defined as [lo, hi] . public static int numOfCombinations(final int[] data, final int lo, final int hi, int beg,