How can the following simple implementation of sum be faster?
sum
private long sum( int [] a, int begin, int end ) { if( a == null ) { ret
If this is based on the actual sample problem, your issue isn't the sum. Your issue is how you calculate the equilibrium index. A naive implementation is O(n^2). An optimal solution is much much better.