题目

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

相关文章:

  • 2018-12-20
  • 2019-03-19
  • 2018-05-14
  • 2018-04-08
  • 2019-03-13
  • 2018-12-22
  • 2018-01-08
  • 2021-11-03
猜你喜欢
  • 2017-12-19
  • 2018-12-13
  • 2018-12-26
  • 2020-03-19
  • 2018-06-27
  • 2018-06-01
  • 2019-12-29
  • 2019-01-05
相关资源
相似解决方案