https://programmers.co.kr/learn/courses/30/lessons/43165
//다른 사람 풀이 (1)
function solution(numbers, target) {
let answer = 0;
function dfs(nodeList, idx) {
if(idx < nodeList.length) {
nodeList[idx] *= 1;
dfs(nodeList, idx+1);
nodeList[idx] *= -1;
dfs(nodeList, idx+1);
} else {
const sum = nodeList.reduce((acc, cur) => acc + cur);
if(sum === target) answer++;
}
}
dfs(numbers, 0);
return answer;
}
dfs, stack, recursion