forked from luliyucoordinate/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1169.py
21 lines (20 loc) · 794 Bytes
/
1169.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Solution:
def invalidTransactions(self, transactions: List[str]) -> List[str]:
data, delt = collections.defaultdict(list), set()
for i, tran in enumerate(transactions):
name, time, amount, city = tran.split(",")
if int(amount) > 1000:
delt.add(i)
data[name].append([int(time), city, i])
for it in data:
data[it].sort()
q = []
for t1, c1, i1 in data[it]:
while q and q[0][0] < t1 - 60:
q.pop(0)
for t2, c2, i2 in q:
if c1 != c2:
delt.add(i2)
delt.add(i1)
q.append([t1, c1, i1])
return [transactions[i] for i in delt]