迷惑的我,做了好几次了还卡着好久,真的💊
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
dic = {}
for key, value in enumerate(nums):
if dic.get(target - value) is not None:
return [key, dic[target-value]]
else:
dic[value] = key
PREVIOUSlc079.单词搜索
NEXTjz026.树的子结构