Starting with a given array of integers and a value 'x'. Calculate the running sum of x plus each array element, from left to right. The running sum must never get below 1. Determine the minimum value of x.
For eg. arr = [-2, 3, 1, -5].
If x = 4, the following results are obtained:
Running
sum arr[i]
----- -----
4 -2
2 3
5 1
6 -5
1
Any ideas how to find this. I tried starting from '0' and slowly incrementing until we reach 1, but thats a wrong approach, I guess.