코딩테스트를 위한 자료구조 및 알고리즘 개론
two-sum¶In [ ]:def twoSum(nums: list[int], target: int) -> list[int]: for i in range(0, len(nums)-1): for j in range(i+1, len(nums)): if nums[i] + nums[j] == target: print(nums[i], nums[j]) return [i, j]twoSum([3, 2, 4], 6)2 4Out[ ]:[1, 2]재귀함수 이용¶In [ ]:def solution(nums, target): n = len(nums) def recur(ans, start): if len(ans) == 2: if nums[ans[0]..
더보기