注意事项:Solution需要实例化对象;语句a=Solution()
class Solution:
def twoSum(self, nums, target):
n=len(nums)
for i in range(n): //第一个元素依次与后方元素相加判断,然后第二个数相同操作
for j in range(i+1,n):
if nums[i]+nums[j]==target:
return [i,j]
return []
if __name__ == '__main__':
nums=[1,2,3,4,5,6,10]
target=3
a=Solution()
print(a.twoSum(nums,target))