标签:ems tco .com code for ble elf 刷题记录 题记
1 两数之和(题目链接)
class Solution: # 一次哈希法 def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ m = {} for i in range(len(nums)): minus = target - nums[i] if minus in m and i != m[minus]: return [i, m[minus]] m[nums[i]] = i return None
标签:ems tco .com code for ble elf 刷题记录 题记
原文地址:https://www.cnblogs.com/weswes/p/10268445.html