class py_solution:  
   def twoSum(self, nums, target):  
        lookup = {}  
        for i, num in enumerate(nums):  
            if target - num in lookup:  
                return (lookup[target - num] + 1, i + 1)  
            lookup[num] = i  #{10:2,20:1}
print("index1=%d, index2=%d" % py_solution().twoSum((10,20,10,40,50,60,70),50))

 

相关文章:

  • 2021-11-18
  • 2021-11-18
  • 2021-12-19
  • 2022-03-08
  • 2021-09-06
  • 2021-05-23
  • 2021-11-06
  • 2021-06-03
猜你喜欢
  • 2022-12-23
  • 2021-08-02
  • 2022-02-05
  • 2021-12-10
  • 2021-12-10
  • 2021-12-10
  • 2021-12-10
相关资源
相似解决方案