Duplicate Transactions Within 60 Seconds
Updated
Problem statement
A card system receives a stream of transactions in time order. Transaction i happened at second timestamps[i], on account accounts[i], at merchant merchants[i], for amounts[i] cents.
Transaction j is a duplicate if some earlier transaction i (with i < j) has:
- the same account, the same merchant and the same amount, and
timestamps[j] - timestamps[i] <= 60.
The earlier transaction can itself be a duplicate. Two transactions in the same second also count, since their difference is 0.
Return the indices of all duplicate transactions in increasing order. Return an empty array if there are none.
Function
findDuplicateTransactions(timestamps: int[], accounts: String[], merchants: String[], amounts: int[]) → int[]Examples
Example 1
timestamps = [0,20,45,70,200]accounts = ["a1","a1","a1","b2","a1"]merchants = ["shop","shop","cafe","shop","shop"]amounts = [500,500,500,500,500]return = [1]- Transaction
1matches transaction0(accounta1, merchantshop, 500 cents) and comes 20 seconds later, so it is a duplicate. - Transaction
2is at a different merchant, and transaction3is on a different account. - Transaction
4matches transactions0and1, but the closer one, transaction1, is 180 seconds earlier. It is not a duplicate.
Example 2
timestamps = [100,160,220,281]accounts = ["c3","c3","c3","c3"]merchants = ["gas","gas","gas","gas"]amounts = [4000,4000,4000,4000]return = [1,2]- Transaction
1comes exactly 60 seconds after transaction0. That still counts, so it is a duplicate. - Transaction
2is 120 seconds after transaction0, but only 60 seconds after transaction1, so it is a duplicate too. - Transaction
3is 61 seconds after transaction2, its nearest match, so it is not a duplicate.
Example 3
timestamps = [5,5,9]accounts = ["x","x","x"]merchants = ["m","m","m"]amounts = [100,250,100]return = [2]- Transactions
0and1happen in the same second, but their amounts differ. - Transaction
2matches transaction0and comes 4 seconds later, so the answer is[2].
Constraints
1 <= timestamps.length <= 10^4accounts.length == merchants.length == amounts.length == timestamps.length0 <= timestamps[i] <= 10^9timestamps[i - 1] <= timestamps[i]for everyi >= 11 <= accounts[i].length, merchants[i].length <= 10accounts[i]andmerchants[i]contain only lowercase English letters and digits.1 <= amounts[i] <= 10^6
More Capital One Onsite Interview questions
- Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
- Sort ColorsONSITE INTERVIEW · Seen Oct 2026
- Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
- Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
- Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
- Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
- LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
- Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
- Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025
- Most Cost-Effective MachineONSITE INTERVIEW · Seen Sep 2025
Similar questions at other companies
- Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
- Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
- Sliding Window Median of Response TimesGoogle · ONSITE INTERVIEWGoogle interview questions
- Longest Subarray with K Distinct ValuesAmazon · ONSITE INTERVIEW
- Count Equal Code Pairs Within Distance KInfosys · ONSITE INTERVIEWInfosys interview questions
- Longest Subarray with At Most Two Distinct ValuesMoody's Investors Service · ONSITE INTERVIEW
- Maximum Sum of a Unique-Element SubarrayTekion · ONSITE INTERVIEWTekion interview questions
- Sliding Window: Target Containment and Most-Repeated WindowRoblox · ONSITE INTERVIEWRoblox interview questions
- Invalid Transactions in Time OrderBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Sliding Window MedianNotion · ONSITE INTERVIEWNotion interview questions
Capital One interview experiences
- Capital One Experienced Engineer Power Day and OA: 6 Experiences
- Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
- Capital One TDP Agentic Round (AI Coding): 7 Experiences
- Capital One SWE Power Day, Level Not Reported: 6 Experiences
- Capital One TIP Intern OA and Power Day: 13 Experiences
- Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)