a = [1,2,3,45,6,17,8,90,8,6,4,5,6,7,0,6]
target = 10
cache = {}
for index,i in enumerate(a):
if target-i in cache.keys():
print('a[{}]:{} and a[{}]:{}'.format(index,i,cache[target-i],target-i))
break
cache[i]=index
a = [1,2,3,45,6,17,8,90,8,6,4,5,6,7,0,6]
target = 10
cache = {}
for index,i in enumerate(a):
if target-i in cache.keys():
print('a[{}]:{} and a[{}]:{}'.format(index,i,cache[target-i],target-i))
break
cache[i]=index
本文标题:2019-03-20
本文链接:https://www.haomeiwen.com/subject/hgutvqtx.html
网友评论