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

题目:

题解:

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嘎嘎嵌入式开发21 小时前
(2)100天python从入门到拿捏
开发语言·python
Stanford_110621 小时前
如何利用Python进行数据分析与可视化的具体操作指南
开发语言·c++·python·微信小程序·微信公众平台·twitter·微信开放平台
Vallelonga1 天前
Rust 中的数组和数组切片引用
开发语言·rust
Kiri霧1 天前
Rust模式匹配详解
开发语言·windows·rust
white-persist1 天前
Python实例方法与Python类的构造方法全解析
开发语言·前端·python·原型模式
千里马-horse1 天前
Async++ 源码分析8--partitioner.h
开发语言·c++·async++·partitioner
Java 码农1 天前
Centos7 maven 安装
java·python·centos·maven
Lucis__1 天前
再探类&对象——C++入门进阶
开发语言·c++
007php0071 天前
某大厂跳动面试:计算机网络相关问题解析与总结
java·开发语言·学习·计算机网络·mysql·面试·职场和发展
倔强青铜三1 天前
苦练Python第63天:零基础玩转TOML配置读写,tomllib模块实战
人工智能·python·面试