Nov-27-2019, 02:27 PM
@buran with regards to runtime considerations your solution is not optimal.
Searching through spam.values() is slower than through a normal list
In worst case, if value is last item in spam.values() you iterate twice over all items in dictionary.
Using my code you iterate only once even in worst case.
Searching through spam.values() is slower than through a normal list
In worst case, if value is last item in spam.values() you iterate twice over all items in dictionary.
Using my code you iterate only once even in worst case.