https://programmers.co.kr/learn/courses/30/lessons/43165
level1
def solution(numbers, target):
answer = 0
def dfs(idx=0):
if idx < len(numbers):
numbers[idx] *= 1
dfs(idx+1)
numbers[idx] *= -1
dfs(idx+1)
elif sum(numbers) == target:
nonlocal answer
answer += 1
dfs()
return answer
'algorithm > python' 카테고리의 다른 글
hackerrank/Data Structures/Arrays/Dynamic Array (0) | 2021.07.18 |
---|---|
카카오블라인드/2020/가사검색 (0) | 2020.07.27 |
프로그래머스/탐욕법/체육복 (0) | 2020.03.16 |
hackerrank/Stacks and Queues/Balanced Brackets (0) | 2020.03.09 |
hackerrank/Hash Tables/Ransom Note (0) | 2020.03.09 |