題目連結 : Two Sum – LeetCode
Python
#Two Sum - #1
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
found = False
for i in range(len(nums)):
for j in range(len(nums)):
if nums[i] + nums[j] == target and i!=j:
found = True
return (i,j)
break
if found:
break