Description
Given array of transactions [cost, cashback], you must complete all in some order. Return minimum starting money to guarantee completion.
Examples
Input:
transactions = [[2,1],[5,0],[4,2]]Output:
10Explanation:
Need 10 to complete.
Input:
transactions = [[1]]Output:
1Explanation:
Minimal case with a single-element matrix.
Input:
transactions = [[3,4],[6,1],[2,3]]Output:
11Explanation:
A minimum of 11 is needed to complete all transactions without the balance ever going negative.
Constraints
- •
1 ≤ transactions.length ≤ 10⁵