LeetCode 1169. Python3 dictionary with brutal force
原题链接
中等
作者:
Gyp
,
2020-04-21 00:41:36
,
所有人可见
,
阅读 553
class Solution:
def invalidTransactions(self, transactions: List[str]) -> List[str]:
d = collections.defaultdict(list)
for t in transactions:
name, ti, am, city = t.split(",")
d[name].append([int(ti),int(am),city,t])
ans = []
for n in d:
for i in range(len(d[n])):
if d[n][i][1] > 1000:
ans.append(d[n][i][3])
for i in range(0,len(d[n])-1):
for j in range(i+1, len(d[n])):
if d[n][i][2] != d[n][j][2] and abs(d[n][j][0] - d[n][i][0]) <= 60:
ans.append(d[n][j][3])
ans.append(d[n][i][3])
return list(set(ans))