<分区>
在 Python 中,我们知道在字典中查找键需要 O(1) 运行时间,但在 dictionary.values() 中查找的运行时间是多少?
dictionary = {'a':[66,77,88], 'b':[99,100]}
key = 'a'
if key in dictionary: # takes O(1) run time
number = '99'
if number in dictionary.values(): # What is the run time here?
编辑 #1:键的值可以是列表或集合。许多人回应说,如果值是列表,则运行时间是 O(1)。
如果值是集合,会是 O(N) 吗?
dictionary = {'a':(66,77,88), 'b':(99,100)}
number = '99'
if number in dictionary.values(): # What is the run time here?