diff --git a/src/inf/recursive,dfs/12.js b/src/inf/recursive,dfs/12.js index 0f6395e7..dbecbbf8 100644 --- a/src/inf/recursive,dfs/12.js +++ b/src/inf/recursive,dfs/12.js @@ -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; diff --git a/src/inf/recursive,dfs/12_re.js b/src/inf/recursive,dfs/12_re.js new file mode 100644 index 00000000..0086ad45 --- /dev/null +++ b/src/inf/recursive,dfs/12_re.js @@ -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)); + diff --git a/src/inf/recursive,dfs/README.md b/src/inf/recursive,dfs/README.md index 0effe85c..9e0aa7ea 100644 --- a/src/inf/recursive,dfs/README.md +++ b/src/inf/recursive,dfs/README.md @@ -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||| \ No newline at end of file