2 Star 0 Fork 0

ShiboJiang / per_leetcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1.两数之和.py 458 Bytes
一键复制 编辑 原始数据 按行查看 历史
Shibo Jiang 提交于 2020-01-04 22:51 . Update 1 new way
#
# @lc app=leetcode.cn id=1 lang=python3
#
# [1] 两数之和
#
# @lc code=start
class Solution:
def twoSum(self, nums, target):
hash_map = dict()
tp_rtn = list()
for i,num in enumerate(nums):
tp_add = target-num
if tp_add in hash_map.keys():
tp_rtn = [hash_map[tp_add],i]
break
else:
hash_map[num] = i
return tp_rtn
# @lc code=end
1
https://gitee.com/qq353838430/per_leetcode.git
git@gitee.com:qq353838430/per_leetcode.git
qq353838430
per_leetcode
per_leetcode
master

搜索帮助