-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#30 4 > 25.01.02 > 피보나치 수 - tabulation 방법
- Loading branch information
Showing
2 changed files
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// ---------------------------------------------------------------------- | ||
/** | ||
* 🔍 피보나치 수 | O | 25.01.02 🔍 | ||
*/ | ||
const N = Number( | ||
require("fs").readFileSync("/dev/stdin").toString().trim().split("\n") | ||
); | ||
|
||
// ✅ 내 풀이 - Tabulation (for문, bottom-up 방식) | ||
const dp = Array.from({ length: N + 1 }, () => 0); | ||
|
||
dp[1] = 1; | ||
dp[2] = 1; | ||
|
||
for (let i = 3; i <= N; i++) { | ||
dp[i] = dp[i - 1] + dp[i - 2]; | ||
} | ||
console.log(dp[N]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# I_LOW | ||
|
||
| 학습일 | 목차 | 주제 | 제목 및 정답여부 | | ||
| :----------------: | :--------- | :--------------------------------------------------------------- | :----------------------------------------------------------------------------------- | | ||
| 24.09.23-24, 09.27 | Simulation | [격자 안에서 완전탐색](./Simulation/격자%20안에서%20완전탐색.js) | 최고의 33위치 (O)<br>행복한 수열의 개수 (O)<br>트로미노 (△)⭐️<br>금 채굴하기 (X)⭐️ | | ||
| 학습일 | 목차 | 주제 | 제목 및 정답여부 | | ||
| :----------------: | :--------- | :------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------- | | ||
| 24.09.23-24, 09.27 | Simulation | [격자 안에서 완전탐색](./Simulation/격자%20안에서%20완전탐색.js) | 최고의 33위치 (O)<br>행복한 수열의 개수 (O)<br>트로미노 (△)⭐️<br>금 채굴하기 (X)⭐️ | | ||
| 25.01.02 | DP 1 | [subproblem을 그대로 합치면 되는 DP](./DP%201/subproblem을%20그대로%20합치면%20되는%20DP.js) | 피보나치 수 (O)<br> | |