An account processes transactions in order (positive = deposit, negative = withdrawal). The bank requires the balance to be at least 1 after every transaction. Return the smallest positive integer opening balance that satisfies this rule.
Examples
Input: transactions = [-2, 3, -4, 1, -1]
Output: 4
Explanation: starting at 4 the balances are 2, 5, 1, 2, 1; starting at 3 the third balance would be 0.
Input: transactions = [4, 6]
Output: 1
Input: transactions = [2, -3, -2]
Output: 4
Constraints
0 <= len(transactions) <= 10**5(an empty list needs an opening balance of 1)-10**4 <= transactions[i] <= 10**4- Target complexity: O(n) time, O(1) extra space.
Goals
- Track the lowest running total
- Turn a 'never below one' requirement into a formula