diff --git a/src/cote/README.md b/src/cote/README.md index bfd17848..03464c04 100644 --- a/src/cote/README.md +++ b/src/cote/README.md @@ -5,4 +5,5 @@ |2|[구현](./implementation/)|[상하좌우](./implementation/imple_ex01.js)
[시각](./implementation/imple_ex02.js)
[왕실의 나이트](./implementation/imple_01.js)
[게임 개발](./implementation/imple_02.js)
-
[럭키 스트레이트](./implementation/test_01.js)
[문자열 재정렬](./implementation/test_02.js)
|22.07.15



-
22.07.20
22.07.23
|△


X
-
O
O|[22.07.17](./implementation/../replay_01.js)
[22.07.18](./implementation/replay_02.js)
[22.07.19](./implementation//replay_03.js)
[22.07.19](./implementation/replay_04.js)
-
X
X| |3|[DFS, BFS](./dfs%2Cbfs/)|[DFS 예제](./dfs%2Cbfs/dfs_ex.js)
[BFS 예제](./dfs%2Cbfs/dfs_ex.js)
[음료수 얼려 먹기](./dfs%2Cbfs/dfs%2Cbfs_01.js)
[미로 탈출](./dfs%2Cbfs/dfs%2Cbfs_02.js)
-
응|22.07.15

22.07.21
22.07.22
-
응|O
O
X
X
-
응|O
O
O
O
-
ㅇ| |4|[정렬](./sort/)|[위에서 아래로](./sort/sort_ex_01.js)
[성적이 낮은 순서로 학생 출력하기](./sort/sort_ex_02.js)
[두 배열의 원소 교체](./sort/sort_ex_03.js)
-
[국영수](./sort/test_01.js)
[안테나](./sort/test_02.js)|22.07.22
22.07.24

-
22.07.25
22.07.28
|O
O
O
-
O
O|X
X
X
-
O
X| -|5|[이진 탐색](./binarySearch/)|[부품 찾기](./binarySearch/ex_01.js)
[떡볶이 떡 만들기](./binarySearch/ex_02.js)
-
[정렬된 배열에서 특정 수의 개수 구하기](./binarySearch/test_01.js)
[고정점 찾기](./binarySearch/test_02.js)
|22.07.27

-
22.07.29
22.07.29
|X
O
-
X
X
|O
X
-
O
O
| \ No newline at end of file +|5|[이진 탐색](./binarySearch/)|[부품 찾기](./binarySearch/ex_01.js)
[떡볶이 떡 만들기](./binarySearch/ex_02.js)
-
[정렬된 배열에서 특정 수의 개수 구하기](./binarySearch/test_01.js)
[고정점 찾기](./binarySearch/test_02.js)
|22.07.27

-
22.07.29
22.07.29
|X
O
-
X
X
|O
X
-
O
O
| +|6|[DP](./dp/)|[1로 만들기](./dp/ex_01.js)|22.08.01|X|O| \ No newline at end of file diff --git a/src/cote/dp/ex_01.js b/src/cote/dp/ex_01.js new file mode 100644 index 00000000..4c46cbc0 --- /dev/null +++ b/src/cote/dp/ex_01.js @@ -0,0 +1,16 @@ +'use strict'; + +function solution(x) { + let d = Array.from({length: x+1}, () => 0); + for(let i = 2; i < x+1; i++) { + // 현재 값에서 1을 빼는 경우 + d[i] = d[i-1] +1; + + if(i%2 === 0) d[i] = Math.min(d[i], d[i/2]+1); + if(i%3 === 0) d[i] = Math.min(d[i], d[i/3]+1); + if(i%5 === 0) d[i] = Math.min(d[i], d[i/5]+1); + } + return d[x]; +} + +console.log(solution(26)); \ No newline at end of file