Invalid Transactions in Time Order
Problem statement
Each string in transactions has the form name,time,amount,city. The array is already sorted by nondecreasing integer time.
A transaction is invalid when at least one condition holds:
amount > 1000.- Another transaction has the same
name, occurs within 60 minutes inclusive, and has a differentcity.
Return every invalid original transaction string in input order. A conflicting pair makes both transactions invalid.
Function
invalidTransactionsSorted(transactions: String[]) → String[]Examples
Example 1
transactions = ["alice,20,800,mtv","alice,50,1200,mtv"]return = ["alice,50,1200,mtv"]The second amount exceeds 1000. The shared city means the first transaction is not invalidated by the time rule.
Example 2
transactions = ["alice,20,800,mtv","alice,50,100,beijing"]return = ["alice,20,800,mtv","alice,50,100,beijing"]The two transactions share a name, differ in city, and are 30 minutes apart, so both are invalid.
Example 3
transactions = ["alice,20,800,mtv","alice,90,100,beijing","bob,100,100,mtv"]return = []Alice's transactions are 70 minutes apart, and Bob has no same-name comparison.
Constraints
1 <= transactions.length <= 100000.- Each row has exactly four comma-separated fields.
nameandcitycontain 1 through 20 lowercase English letters.0 <= time <= 10^9, and input times are nondecreasing.0 <= amount <= 10^9.