leetcode 热题100 两数之和

class Solution(object):

def twoSum(self, nums, target):

"""

:type nums: Listint

:type target: int

:rtype: Listint

"""

myDict = {}

for i,t in enumerate(nums):

myDictnums\[i] = i

for i,t in enumerate(nums):

tmp = target - t

if myDict.get(tmp)!=None and myDict.get(tmp)!=i:

return i,myDict.get(tmp)

相关推荐
Navigator_Z12 分钟前
LeetCode //C - 1223. Dice Roll Simulation
c语言·算法·leetcode
171320330计算机毕设编程14 分钟前
2027计算机毕设五大方向对比&选题推荐
java·ide·python·算法·django·php·推荐算法
Tisfy17 分钟前
LeetCode 2058.找出临界点之间的最小和最大距离:遍历+遇到极值则更新(这种题谁空间复杂度不是O(1)啊)
linux·数据库·leetcode·链表·题解·模拟·遍历
万物智能27 分钟前
设备树DTS-【万物智能之开源鸿蒙OpenHarmony系统实战开发系列教程】
后端·算法
代码不停34 分钟前
子数组问题
java·算法
小欣加油42 分钟前
Leetcode2058 找出临界点之间的最小和最大距离
数据结构·c++·算法·leetcode·职场和发展
华华哥20221 小时前
《模型不玄学》第25章 双头模型:共享底座 + 两个分支
算法
Yfhonier1 小时前
6441. 特别的除法
c++·算法
华华哥20221 小时前
《模型不玄学》第5章 看懂你的数据:先认字段,再过门禁
算法