Company: Goldman sachs_27july
Difficulty: medium
Traveler Fund Problem Description A traveler is traveling form city of zeta to omega. He starts with X amount of money. Every day he spends some money and also he may work on some days to earn money. He may find good work some day and end up earning more than what he spends that day. It also may happen that he spends more than what he earns on any day. You are given an array of integers which represents his net savings (earning -expense) on any day. You need to find out minimum amount the traveler should begin with to ensure that he always have some money (>0) at the end of any day. Constraints -200 <= a i <= 200, where a i are array elements 0 < i <= 100, where i is the array length X >= 0 Examples Example 1: Input: 3 //Array length 4 //Array elements start 2 -3 Output: 0 Explanation: Traveler saves $4 on first day, $2 on second day and $-3 on third day (expense is more on 3 day than earnings). End of the first day, he has X + $4 End of the Second day, he has X + $(4+2)