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)

相关推荐
程序员清风1 小时前
算法题中的边界条件、测试与调试
开发语言·算法·kotlin
炘爚1 小时前
数据结构算法总结
数据结构·python·算法
Dageno_AI2 小时前
ChatGPT 不再引用 Reddit 之后,还值得在 Reddit 上做 AI 可见度吗?
算法
hetao17338372 小时前
2026-10-25 hetao1733837 的刷题记录
c++·算法
Jsundoku2 小时前
第七章 机器学习 -- 其他经典算法
人工智能·算法·机器学习
进击的丸子2 小时前
基于 ArcFace SDK 的跨平台人脸特征值下发、同步以及存储方案
后端·算法·代码规范
见叶之秋2 小时前
【C++】红与黑的边界:红黑树从插入到自检
数据结构·c++·算法·面试
考研保研资料分享2 小时前
2023历史学跨保山大马理论:两轮笔面试、课程论文与方向取舍
面试·职场和发展
一条闲鱼_mytube3 小时前
分布式 ID 生成方案:雪花算法与号段模式
分布式·算法·wpf
Msir_Modern3 小时前
Noita 元胞沙盒笔记
算法·unity·c#·游戏引擎·元胞自动机