Flag Possible Duplicate Vendor Payments in Accounts Payable
Last updated: November 29, 2026
Quick Overview
Given a list of vendor payments with id, vendor, amount, day number and free-text invoice number, return every pair of payments that is likely a duplicate: same vendor and amount within a 7 day window, or same vendor and the same invoice number after normalization.
Deloitte
November 29, 20260
0
0 solved
Given a list of vendor payments with id, vendor, amount, day number and free-text invoice number, return every pair of payments that is likely a duplicate: same vendor and amount within a 7 day window, or same vendor and the same invoice number after normalization.
Duplicate payment detection is a classic accounts payable analytic that audit and forensic teams run over client ledgers, and it maps directly to the journal analytics Deloitte builds into its audit tooling. The interviewer is checking that you group before comparing, use a sliding window instead of all pairs, and think hard about messy invoice numbers.
What the Interviewer Expects
- Groups by (vendor, amount) and by (vendor, normalized invoice) before comparing
- Uses sorting plus a sliding window for the date rule
- Normalizes invoice numbers (prefixes, punctuation, leading zeros) deliberately
- Deduplicates pairs flagged by both rules and records the reason
- Discusses false positives such as recurring fixed-fee invoices
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Monthly rent to the same landlord is the same amount every month. How do you avoid flagging it?
- How would you catch near-duplicates where one digit of the amount was mistyped?
- How would you rank flagged pairs so an auditor reviews the riskiest first?
- How would you run this across 200 million payments in Spark?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Each payment: id, vendor, amount_cents, day, invoice. Two rules:
- Same vendor, same amount, days at most
window_daysapart. - Same vendor, same normalized invoice number, any amount (a partial ...
High-Level Design
Comparing all pairs is O(n^2) over a client's whole AP history, which is far too slow. Instead bucket by (vendor, amount); inside each bucket sort by day and slide a window so each payment only meet...