The solution is to store accumulated sums into a state vector. But is that really dynamic programming or there is some other solution?
I think the way to computer the sum vector is the simplest dynamic programming example.
sum[i] = sum[i-1] + nums[i];
Since you don't sum all the numbers from nums to nums[i].
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.