[Leetcode]#1 Two Sum

Posted 夜歌乘年少

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Leetcode]#1 Two Sum相关的知识,希望对你有一定的参考价值。

class Solution:
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """

        for index1 in range(len(nums)):
            for index2 in range(index1 + 1, len(nums)):
                if nums[index1] + nums[index2] == target:
                    return [index1, index2]

 

 

 

还以为必然timeout 结果并没有 不过7秒多也惨不忍睹了

以上是关于[Leetcode]#1 Two Sum的主要内容,如果未能解决你的问题,请参考以下文章

[LeetCode] 1 Two Sum

[LeetCode] 1 Two Sum

LeetCode之371. Sum of Two Integers

leetcode 1.Two sum

Leetcode 1. Two Sum (Python)

LeetCode #1 - Two Sum