Given an array of integers,
In other words, let inputArray by an integer array of length 'n'. The solution, computed into outputArray, would be:
for each j from 1 to n2:
outputArr[ j ] = inputArray[0] + inputArray[1] + inputArray[2] + ... + inputArray[j1] + inputArray[j+1] + inputArray[j+2] +...+ inputArray[n1]
for j = 0:
outputArray[0] = inputArray[1] + outputArray[2] + ... + outputArray[n1]
for j = n1
outputArray[n1] = outputArray[0] + outputArray[1] + outputArray[2] + ... + outputArray[n2]
For example, the inputArray: { 1, 2, 3, 4 }
returns outputArray: { 9, 8, 7, 6 }
which is nothing but { 2+3+4, 1+3+4, 1+2+4, 1+2+3 }.
Notes:
The input array size will always have at least two elements in it, that is, n >= 2.
You could treat all the numbers as integers
The maximum length of input array is 100.