New answers tagged

0

If you are looking for a sum s, and the total of all array elements is t, then the sum of the first i and the last j elements must be t - s, so the elements from index i to index n-j exclusive add up to s. So you create a hash table or a balanced binary tree for the sum of the last j elements, starting with j = 0, then adding another element for j = 1, 2, ...


-1

The above posted solutions looks good. Here is my code for the same. It takes O(n) time to complete. The output from the above program is 2 4. Which means 2nd, 3rd and 4th elements sum gives the value of 9. 2nd Element indicates array index of 1 not 2. class FindArrayProblem { public static void main (String[] args) { int array[] = {1, -3,...


2

AFAIK, there are no such tools. Google didn't find one for me. But feel free to look again :-) Actually, I wouldn't expect a standalone tool to either be accurate ... or generally useful. It is unlikely to be accurate because there are all sorts of factors in a typical application that distort the performance data that you can measure "from the outside"...



Top 50 recent answers are included