https://programmers.co.kr/learn/courses/30/lessons/43165
class Solution {
static boolean use[];
static int nums[];
static int tg;
static int cnt;
static int sum=0;
public int solution(int[] numbers, int target) {
cnt = 0;
nums = numbers;
use = new boolean[numbers.length];
tg = target;
dfs(0,0);
return cnt;
}
public void dfs(int sum,int start){
if(start==nums.length){
if(sum==tg){
cnt++;
}
return;
}
dfs(sum+nums[start],start+1);
dfs(sum-nums[start],start+1);
}
}