-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransaction Logs.py
37 lines (36 loc) · 1.02 KB
/
Transaction Logs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def processLogFile(logs, threshold):
"""
:type logs: List[str]
:type threshold: int
:rtype: List[str]
"""
amount = []
users = []
for i in range(len(logs)):
a, b, c = logs[i].split(" ")
if (a == b):
if (a in users):
index = users.index(a)
amount[index] += 1
else:
users.append(a)
amount.append(1)
else:
if (a in users):
index = users.index(a)
amount[index] += 1
else:
users.append(a)
amount.append(1)
if (b in users):
index = users.index(b)
amount[index] += 1
else:
users.append(b)
amount.append(1)
returnedArray = []
for i in range(len(amount)):
if amount[i] >= threshold:
returnedArray.append(users[i])
returnedArray.sort()
return returnedArray