All problems
0001EasyArrayHash Table

Ledger Reconciliation

Tracked in this browser only
Write code

Trains the technique from

LeetCode 1Two Sum

This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.

Same function shape, different story and different numbers.

An accountant is closing out a ledger. You are given an integer array adjustments, where each entry is a signed correction applied to an account, and an integer net.

Exactly one pair of entries sums to net. Return the indices of those two entries, in any order. An entry cannot be paired with itself.

Examples

Example 1

Input
adjustments = [7, -3, 11, 2], net = 8
Output
[1, 2]

The entry at index 1 holds -3 and the entry at index 2 holds 11, which together settle to 8.

Example 2

Input
adjustments = [-5, -5, 4], net = -10
Output
[0, 1]

Both entries hold the same amount but occupy separate positions, so pairing them is allowed.

Example 3

Input
adjustments = [6, 1], net = 7
Output
[0, 1]

With only two entries available, they must be the settling pair.

Constraints

  • 2 <= adjustments.length <= 10^4
  • -10^9 <= adjustments[i] <= 10^9
  • -10^9 <= net <= 10^9
  • Exactly one valid pair exists

The values you return may be in any order.

The signature

The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.

Python
def reconcile_ledger(adjustments: list[int], net: int) -> list[int]:
Java
public int[] reconcileLedger(int[] adjustments, int net)
September 7
Apply