Link : programmers.co.kr/learn/courses/30/lessons/43165
Python
더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
counter = 0
def DFS(numbers, target, deapth, length):
global counter
if deapth == length:
if sum(numbers) == target:
counter += 1
else:
numbers[deapth] *= -1
DFS(numbers, target, deapth + 1, length)
numbers[deapth] *= -1
DFS(numbers, target, deapth + 1, length)
def solution(numbers, target):
DFS(numbers, target, 0, len(numbers))
return counter
|
cs |
FeedBack
cjw.git@gmail.com
'알고리즘 > 소스코드' 카테고리의 다른 글
PROGRAMMERS 42860: 조이스틱 (0) | 2021.01.06 |
---|---|
PROGRAMMERS 43238: 입국 심사 (0) | 2021.01.05 |
PROGRAMMERS 42885: 구명보트 (0) | 2021.01.05 |
PROGRAMMERS 42583: 다리를 지나는 트럭 (0) | 2021.01.05 |
PROGRAMMERS 42586: 기능개발 (0) | 2021.01.05 |
댓글