leetle

Daily challenge for 2026-10-20

658. Total Active Invoice Balance

You are given a list of invoices, where each invoice is represented as a pair of integers [id, amount]. Each invoice has a unique identifier id and an integer balance amount.

You are also given a list of integer identifiers cancelled representing invoices that have been cancelled. The list cancelled may contain duplicate IDs or IDs that do not appear in the invoice list.

Return the total sum of amounts for all invoices that have not been cancelled.

Constraints:
There are at most 1,000 invoices and 1,000 cancellation entries. Invoice ids are unique integers. Amounts may be negative. All integer values have absolute value at most 1,000,000; cancelled ids may repeat or be absent from the invoices.

Example:
Input: invoices = [[101, 50], [102, 100], [103, 30]], cancelled = [102, 104]
Output: 80

Run this challenge interactively in Python or JavaScript when the app loads.