UPI Merchant Reconcile
An Indian payment processor reconciles two streams at the end of each day: the merchant's claimed receipts and the bank's actual settlement file. Each row in both streams is a transaction reference (a UTR string) and a paise amount. Both streams are already sorted by UTR ascending. Find the reconciled pairs (same UTR, same amount).
Problem
You are given two arrays merchant and bank. Each entry is a pair (utr, amount). Both arrays are sorted ascending by utr (lexicographically). Return the list of (utr, amount) pairs that appear in BOTH streams with identical amounts. Preserve the sorted UTR order in the output.
Input
Integers m and n (1 ≤ m, n ≤ 10^5), the merchant array, and the bank array. utr is a 12-char ASCII string; amount is an integer in [1, 10^11] paise.
Output
A list of (utr, amount) pairs sorted by utr.
Constraints
- 1 ≤ m, n ≤ 100,000
- Both inputs already sorted ascending by utr
- amounts are int64 paise values; an exact match is required
- UTRs are unique within each stream
Examples
Example 1
Input
merchant = [("A001",100), ("A003",250), ("A005",400)]
bank = [("A001",100), ("A002",200), ("A005",400)]Output
[("A001",100), ("A005",400)]A001 matches in both with amount 100. A005 matches in both with amount 400. A003 and A002 are only in one stream.
Example 2
Input
merchant = [("X1", 50)]
bank = [("X1", 60)]Output
[]
Same UTR but mismatched amount — not a reconciled pair.