[LeetCode] 1. Two Sum

1 class Solution:
2     def twoSum(self, nums: List[int], target: int) -> List[int]:
3         for i in range(len(nums)):
4             if (target - nums[i]) in nums and i != nums.index(target - nums[i]):
5                 return [i, nums.index(target - nums[i])]
相關文章
相關標籤/搜索