Tap here to switch tabs
Problem
Submissions

Problem: Minimum Money Required Before Transactions

Minimum Money Required Before Transactions lists each transaction's cost and cashback. Return the least initial money needed to pay each cost and complete every transaction in any order.

Statement

You are given an array transactions where transactions[i] = [cost_i, cashback_i].

The array represents a series of transactions that must be completed:

  • You must possess at least cost_i money before performing the transaction.

  • After paying cost_i, you receive cashback_i.

Return the minimum initial amount of money required so that all transactions can be completed regardless of the order in which they are processed.

Constraints:

  • 1≤1 \leq transactions.length ≤105\leq 10^5

  • transactions[i].length =2= 2

  • 0≤0 \leq cost_i, cashback_i ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Money Required Before Transactions

Minimum Money Required Before Transactions lists each transaction's cost and cashback. Return the least initial money needed to pay each cost and complete every transaction in any order.

Statement

You are given an array transactions where transactions[i] = [cost_i, cashback_i].

The array represents a series of transactions that must be completed:

  • You must possess at least cost_i money before performing the transaction.

  • After paying cost_i, you receive cashback_i.

Return the minimum initial amount of money required so that all transactions can be completed regardless of the order in which they are processed.

Constraints:

  • 1≤1 \leq transactions.length ≤105\leq 10^5

  • transactions[i].length =2= 2

  • 0≤0 \leq cost_i, cashback_i ≤109\leq 10^9