๋ฌธ์
https://school.programmers.co.kr/learn/courses/30/lessons/43165
ํ์ด
# ํ๋ก๊ทธ๋๋จธ์ค 2๋จ๊ณ - ํ๊ฒ ๋๋ฒ
def solution(numbers, target):
n = len(numbers)
answer = 0
def dfs(idx, result):
if idx == n:
if result == target:
nonlocal answer
answer += 1
return
else:
dfs(idx+1, result+numbers[idx])
dfs(idx+1, result-numbers[idx])
dfs(0,0)
return answer