Skip to content

Commit

Permalink
#8 22.05.26 > 12번 조합문제
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed May 26, 2022
1 parent 96dcadd commit 25da6b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/inf/recursive,dfs/12.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function solution(n ,r) {
function dfs(n, r) {
if(dy[n][r]>0) return dy[n][r];
if(n === r || r === 0) return 1;
else return dfs(n-1, r-1) + dfs(n-1, r);
else return dy[n][r]=DFS(n-1, r-1)+DFS(n-1, r);
}
answer = dfs(n, r);
return answer;
Expand Down
20 changes: 20 additions & 0 deletions src/inf/recursive,dfs/12_re.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

function solution(n, r) {
let answer;
let arrSize = n+2;
let dy = Array.from(Array(arrSize), () => Array(arrSize).fill(0));
function dfs(n, r) {
if(dy[n][r] > 0) return dy[n][r];
if(n === r || r === 0) {
return 1;
} else {
return dy[n][r] = dfs(n-1, r-1)+dfs(n-1, r);
}
}
answer = dfs(n, r);
return dfs(n, r);
}

console.log(solution(33, 20));

4 changes: 2 additions & 2 deletions src/inf/recursive,dfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
|7||O|
|8|X|O|
|9||O|
|10||O그치만 다시!|
|10||O 한번 더 보기|
|11|O|O|
|12|||
|12|X|O 한번 더 보기|
|13|||
|14|||
|15|||

0 comments on commit 25da6b2

Please sign in to comment.