finish extra/minion-work-assignments #28
@ -114,3 +114,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM
|
||||
|
||||
### re-id
|
||||
* Completed in: 10 mins, 19 secs.
|
||||
|
||||
### minion-work-assignments
|
||||
* Completed in: 7 mins, 40 secs.
|
||||
|
||||
18
extra/minion-work-assignments/solution.py
Normal file
18
extra/minion-work-assignments/solution.py
Normal file
@ -0,0 +1,18 @@
|
||||
def solution(data, n):
|
||||
memo = {}
|
||||
for i in data:
|
||||
if i not in memo:
|
||||
memo[i] = 1
|
||||
else:
|
||||
memo[i] += 1
|
||||
|
||||
return [d for d in data if memo[d] <= n]
|
||||
|
||||
tests = [
|
||||
([[1, 2, 3], 0], []),
|
||||
([[1, 2, 2, 3, 3, 3, 4, 5, 5], 1], [1, 4]),
|
||||
]
|
||||
|
||||
for i, o in tests:
|
||||
result = solution(*i)
|
||||
print (i, result == o, result, o)
|
||||
Loading…
x
Reference in New Issue
Block a user