Python
단순풀이
class Solution:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
length = len(nums)
for i in range(length - 1):
left = nums[i]
for j in range(i+1, length):
right = nums[j]
sum = left + right
if sum == target:
return [i, j]
solution = Solution()
assert(solution.twoSum([2, 7, 11, 15], 9) == [0, 1])array 에 넣고 검색
Last updated