python leetcode1

来源:互联网 发布:路由器绑定mac 编辑:程序博客网 时间:2024/06/08 19:58

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.
# author:weiclass Solution:   def twoSum(self,list,target):        for j in range(len(list)-1):            if target==list[j]+list[j+1]:                print(j,j+1)a=Solution()a.twoSum([1,2,3,4,7,100,6,356,24,56,44],100)