标签:解答 problems 题记 考虑问题 程序 class 返回 开启 nbsp
在博客园上开启LeeCode刷题记录,希望可以成为一只厉害的程序媛~
1 class Solution(object): 2 def twoSum(self, nums, target): 3 """ 4 :type nums: List[int] 5 :type target: int 6 :rtype: List[int] 7 """ 8 n = len(nums) 9 indexs = [] 10 for i in range(0,n): #i是下标 11 j = target - nums[i] #j是值 12 if j in nums and i != nums.index(j): 13 x = nums.index(j) 14 indexs.append(i) 15 indexs.append(x) 16 indexs = list(set(indexs)) 17 return indexs
2019-12-31
13:33:56
题目来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/two-sum
标签:解答 problems 题记 考虑问题 程序 class 返回 开启 nbsp
原文地址:https://www.cnblogs.com/RuiRuia/p/12123945.html