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)

相关推荐
剑挑星河月18 分钟前
54.螺旋矩阵
java·算法·leetcode·矩阵
Robot_Nav43 分钟前
MPPI 局部规划器实验设计讲解
人工智能·算法·mppi
mingo_敏1 小时前
Mean-Teacher 均值教师自训练框架详解
算法·均值算法
水木流年追梦1 小时前
agent面试必备31- AI Agent 核心进阶:工具路由(Tool Routing)
数据库·人工智能·oracle·面试·职场和发展·embedding
星空露珠2 小时前
迷你世界UGc3.0脚本Wiki[剧情动画模块管理接口 Timeline]
开发语言·数据结构·算法·游戏·lua
笨笨没好名字2 小时前
Leetcode刷题python3版第一周(下)
linux·算法·leetcode
手写码匠2 小时前
手写 LLM 安全护栏:从内容审核到越狱防御的完整实现
人工智能·深度学习·算法·aigc
luj_17682 小时前
草酸与烟酸对消化及糖代谢的影响解析
服务器·c语言·开发语言·经验分享·算法
青风972 小时前
16-ADAPTRACK:基于自适应阈值的多目标跟踪匹配算法
人工智能·算法·目标跟踪
汤姆yu2 小时前
macOS系统下Aider完整安装、配置与实战使用教程
大数据·人工智能·算法·macos·github·copilot