목표 시간: 60분
소요 시간: 105분
from collections import deque
def solution(numbers, target):
answer = 0
need_visit = deque([(0,0)]) # (숫자,거리)
while need_visit:
cur, dist = need_visit.popleft()
if dist == len(numbers) and cur == target:
answer += 1
if 0<=dist<len(numbers):
num = numbers[dist]
for next in (num,-1*num):
if 0<=dist+1<=len(numbers):
need_visit.append((cur+next,dist+1))
return answer