#1169
Invalid Transactions
expert · 1165 · lc medium +32 · verified · 32.1% accepted · 612 likes · top 10%
Description
A transaction may be flagged as invalid under either of these conditions:
- Its amount exceeds $1000, or
- It occurs within 60 minutes (inclusive) of another transaction sharing the same name but in a different city.
You receive an array of strings transaction where each transactions[i] is a comma-separated record containing the name, time (in minutes), amount, and city.
Return all potentially invalid transactions in any order.
Example 1:
Input: transactions = ["alice,20,800,mtv","alice,50,100,beijing"]
Output: ["alice,20,800,mtv","alice,50,100,beijing"]
Explanation: The first transaction is invalid because the second transaction occurs within a difference of 60 minutes, have the same name and is in a different city. Similarly the second one is invalid too.
Example 2:
Input: transactions = ["alice,20,800,mtv","alice,50,1200,mtv"]
Output: ["alice,50,1200,mtv"]
Example 3:
Input: transactions = ["alice,20,800,mtv","bob,50,1200,mtv"]
Output: ["bob,50,1200,mtv"]
Code
1
2
3