- Climbing steps with 2,4,6
- Leetcode easy level problem: see below
Traveler Fund
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; <=200 , where aj are array elements
O<<=100, where i is the array length
X>=0
For example:
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)
End of third day, he has X + $(4+2-3)