File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.util.* ;
3+
4+ class Solution {
5+ public int [] solution (int [] progresses , int [] speeds ) {
6+ int [] answer = {};
7+ List<Integer > answerList = new ArrayList<Integer > ();
8+ int [] remainDays = new int [progresses. length];
9+
10+ for (int i= 0 ; i< progresses. length; i++ ){
11+ int remain = 100 - progresses[i];
12+
13+ if (remain% speeds[i] == 0 ) {
14+ remainDays[i] = remain/ speeds[i];
15+ } else {
16+ remainDays[i] = remain/ speeds[i] + 1 ;
17+ }
18+ }
19+
20+ int cnt = 1 ;
21+ int days = remainDays[0 ];
22+ for (int i= 1 ; i< progresses. length; i++ ){
23+ if (remainDays[i] > days){
24+ answerList. add(cnt);
25+ cnt = 0 ;
26+ days = remainDays[i];
27+ }
28+ cnt++ ;
29+ }
30+
31+ answerList. add(cnt);
32+ answer = new int [answerList. size()];
33+
34+ for (int i= 0 ; i< answerList. size(); i++ ){
35+ answer[i] = answerList. get(i);
36+ }
37+
38+ return answer;
39+ }
40+ }
41+ ```
You can’t perform that action at this time.
0 commit comments