private int count;
public int solution(int n) {
count = 0;
dfs(0, 0, n);
return count;
}
public void dfs(int left, int right, int n) {
if (left > n || right > n || left < right) {
return;
}
if (left == n && right == n) {
count++;
return;
}
dfs(left + 1, right, n);
dfs(left, right + 1, n);
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/12929