File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,6 @@ function solution(progresses, speeds) {
62
62
return answer ;
63
63
}
64
64
65
-
66
-
67
65
// 정답 4 - createhb21
68
66
function solution ( progresses , speeds ) {
69
67
// answer은 각 배포 때 함께 배포되는 기능의 수를 담은 배열
@@ -89,3 +87,30 @@ function solution(progresses, speeds) {
89
87
answer . push ( queue . length ) ;
90
88
return answer ;
91
89
}
90
+
91
+ // 정답 5 - chaerin-dev
92
+ function solution ( progresses , speeds ) {
93
+ // 각 기능 개발 작업이 끝나기까지 남은 일수를 계산해서 daysLeftArr 배열에 저장
94
+ const daysLeftArr = progresses . map ( ( progress , i ) => Math . ceil ( ( 100 - progress ) / speeds [ i ] ) ) ;
95
+
96
+ // 최초 배포날은 daysLeftArr의 첫 번째 요소
97
+ let deployDay = daysLeftArr [ 0 ] ;
98
+ // 각 배포에 몇 개의 기능이 배포될지 셀 변수
99
+ let cnt = 0 ;
100
+ // 각 배포에 몇 개의 기능이 배포될지 저장할 배열
101
+ const answer = [ ] ;
102
+
103
+ // leftDays 배열을 차례로 순회하며 현재 배포일보다 이후에 배포되어야할 기능을 만나면 이전까지의 기능을 한번에 배포
104
+ daysLeftArr . forEach ( ( daysLeft ) => {
105
+ if ( deployDay < daysLeft ) {
106
+ deployDay = daysLeft ;
107
+ answer . push ( cnt ) ;
108
+ cnt = 0 ;
109
+ }
110
+ cnt ++ ;
111
+ } ) ;
112
+ answer . push ( cnt ) ;
113
+
114
+ // 정답 반환
115
+ return answer ;
116
+ }
You can’t perform that action at this time.
0 commit comments