擅长:python、mysql、java
<pre><code>numbers = {'a': 1, 'b': 4, 'c': 1, 'd':4 , 'e': 3}
mx_tuple = max(numbers.items(),key = lambda x:x[1]) #max function will return a (key,value) tuple of the maximum value from the dictionary
max_list =[i[0] for i in numbers.items() if i[1]==mx_tuple[1]] #my_tuple[1] indicates maximum dictionary items value
print(max_list)
</code></pre>
<p>此代码将在O(n)中工作。在求最大值时为O(n),在列表理解中为O(n)。所以总的来说还是O(n)。</p>
<p>注:O(2n)等于O(n)。</p>