[프로그래머스] 타겟 넘버
class Solution { int answer = 0; public int solution(int[] numbers, int target) { DFS(numbers, 0, target, 0); return answer; } public void DFS(int[] numbers, int depth, int target, int result){ if(numbers.length == depth){ if(target == result) answer++; } else{ DFS(numbers, depth+1, target, result + numbers[depth]); DFS(numbers, depth+1, target, result - numbers[depth]); } } }