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)

相关推荐
ychqsq39 分钟前
201.春风
经验分享·职场和发展
小蒋学算法1 小时前
算法-交替删除操作后最后剩下的整数-跟着灵茶山艾府学算法
数据结构·算法
荆棘鸟智能1 小时前
林业遥感长势评估怎么做?从NDVI时序分析到LiDAR蓄积量回归
人工智能·算法·智慧林业
hhb_6182 小时前
AIRAGDebug:一键定位RAG链路异常
人工智能·python·算法
泡沫_花火2 小时前
大模型开发相关岗位面试资料(含算法)
语言模型·自然语言处理·面试·职场和发展
朝朝辞暮i2 小时前
C++ 第 6 课:switch —— 多状态选择
开发语言·c++·算法
苏打豆3 小时前
Pinocchio源码阅读——刚体运动物理量空间变换及求导
c++·线性代数·算法·矩阵·机器人
FluxArt3 小时前
GPT Image 2.5 中文提示词教程:Flux Art 可复用模板
前端·gpt·算法
思麟呀3 小时前
位运算:从一个整数到一个集合
c语言·数据结构·c++·算法
阜阳山君GEO4 小时前
豆包 SEED 新版本 GEO 优化:信源金字塔、打分体系与避坑落地指南
人工智能·算法