[Programmers] 타겟 넘버
Updated:
문제링크
문제 해설
None
python 코드
def solution(numbers, target):
return func(numbers, target, 0)
def func(numbers, target, val):
if len(numbers) == 1:
if val + numbers[0] == target or val - numbers[0] == target:
return 1
else:
return 0
else:
return func(numbers[1:], target, val + numbers[0]) + func(numbers[1:], target, val - numbers[0])
Leave a comment