I have a situation that is as follows:
Given an array with for example 5 positions [5, 10, 8, 2, 7]
I need an algorithm that will allow me to do the following:
Get 5 and subtract by the numbers that are after your position [10, 8, 2, 7]
Get 10 and subtract by the numbers that are after your position [8, 2, 7]
Get 8 and subtract by the numbers that are after your position [2, 7]
And so on. I need to store the result of these subtractions in a new array.
It can be in any of the two languages.