Last active
December 20, 2020 16:35
-
-
Save 1Mark/c65bd3ab63cc457fbd65a2848e490863 to your computer and use it in GitHub Desktop.
defaultdict_employees_with_highest_salary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m timeit -s "from defaultdict_salary_technique import highest_paid_employees" "highest_paid_employees()" | |
100000 loops, best of 5: 2.5 usec per loop | |
python -m memory_profiler defaultdict_salary_technique.py | |
Filename: defaultdict_salary_technique.py | |
Line # Mem usage Increment Occurences Line Contents | |
============================================================ | |
10 37.953 MiB 37.953 MiB 1 @profile | |
11 def highest_paid_employees(): | |
12 37.953 MiB 0.000 MiB 1 salary_to_employee = defaultdict(list) | |
13 37.953 MiB 0.000 MiB 7 for k, v in salaries.items(): | |
14 37.953 MiB 0.000 MiB 6 salary_to_employee[int(v.rstrip("k"))].append(k) | |
15 | |
16 37.953 MiB 0.000 MiB 1 return salary_to_employee[max(salary_to_employee.keys())] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment