技术栈

Python | Leetcode Python题解之第1题两数之和

Mopes__2024-03-31 11:42

题目:

题解:

python 复制代码
class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        n = len(nums)
        for i in range(n):
            for j in range(i + 1, n):
                if nums[i] + nums[j] == target:
                    return [i, j]
        
        return []
上一篇:每日一题:C语言经典例题之某年某月的天数
下一篇:在Java中什么是JVM?
相关推荐
AI探索者
8 小时前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者
8 小时前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
FishCoderh
10 小时前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅
10 小时前
Python函数入门详解(定义+调用+参数)
python
曲幽
11 小时前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama
两万五千个小时
15 小时前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
哈里谢顿
17 小时前
Python 高并发服务限流终极方案:从原理到生产落地(2026 实战指南)
python
用户835629078051
1 天前
无需 Office:Python 批量转换 PPT 为图片
后端·python
markfeng8
1 天前
Python+Django+H5+MySQL项目搭建
python·django
GinoWi
1 天前
Chapter 2 - Python中的变量和简单的数据类型
python
热门推荐
01GitHub 镜像站点02【OpenClaw 本地实战 Ep.3】突破瓶颈:强制修改 openclaw.json 解锁 32k 上下文记忆03OpenClaw 使用和管理 MCP 完全指南04Clawdbot部署教程:解决‘gateway token missing’授权问题的完整步骤05OpenClaw + 飞书(Feishu)环境搭建指南06Claude Code + GLM4.7 避坑指南:解决 Unable to connect to Anthropic services07Window 10部署openclaw报错node.exe : npm error code 12808AI 规范驱动开发“三剑客”深度对比:Spec-Kit、Kiro 与 OpenSpec 实战指南09AI Agent 平台横评:ZeroClaw vs OpenClaw vs Nanobot10OpenClaw优化飞书API 额度已耗尽问题