public static long convertToPrecedingCummulative ( final long [ ] array ) { long subtotal = 0 ; for ( int i = 0 ; i < array . length ; i ++ ) { final long newSubtotal = subtotal + array [ i ] ; array [ i ] = subtotal ; subtotal = newSubtotal ; } return subtotal ; }
Convert the weights into totals of the weights preceding each item