题目

https://leetcode.com/problems/two-sum/
[Leetcode by python] 1. Two Sum

解题思路

第一次写技术博客,有点小兴奋!

代码

class Solution(object):
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        d = {}
        for i in range(len(nums)):
            if target - nums[i] in d:
                return [d[target-nums[i]], i]
            d[nums[i]] = i

相关文章:

  • 2021-06-08
  • 2021-08-06
  • 2021-08-16
  • 2021-09-14
  • 2022-02-08
  • 2021-06-02
  • 2021-11-28
  • 2021-11-02
猜你喜欢
  • 2021-04-25
  • 2022-01-14
  • 2021-09-25
  • 2021-11-14
  • 2021-09-15
  • 2021-12-24
  • 2021-05-16
相关资源
相似解决方案