Transaction Logs Threshold
EasyHash Map · Amazon
Each entry in logs is a string "sender_id recipient_id amount" with the three fields separated by single spaces. User ids are numeric strings with no leading zeros.
A user takes part in a transaction if they are its sender or its recipient. If the sender and recipient are the same user, that transaction counts only once for them.
Return the ids of all users who take part in at least threshold transactions, as strings, sorted in increasing numeric order (so "9" comes before "23").
Example 1
- Input:
- logs = ["9 100 20", "100 9 5", "100 23 60", "23 23 40"], threshold = 2
- Output:
- ["9", "23", "100"]
- Explanation
- User 9 is in the first two logs (2). User 100 is in the first three (3). User 23 receives once and then sends to itself, which counts once more (2). All three reach 2 and are listed numerically, so
"23"comes before"100".
Example 2
- Input:
- logs = ["9 10 5", "10 9 7", "100 9 2"], threshold = 3
- Output:
- ["9"]
- Explanation
- User 9 appears in all three logs, user 10 in two and user 100 in one, so only user 9 reaches 3.
Example 3
- Input:
- logs = ["4 5 1"], threshold = 2
- Output:
- []
- Explanation
- Each user appears in a single transaction, which is short of the threshold.
Constraints
1 <= logs.length <= 10^5- User ids and amounts are integers between
1and10^9, written without leading zeros 1 <= threshold <= logs.length