File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-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 n = progresses. length;
7+ int [] days = new int [n];
8+
9+ for (int i = 0 ; i < n; i++ ){
10+ int remain = 100 - progresses[i];
11+ if (remain % speeds[i] == 0 ){
12+ days[i] = remain / speeds[i] + 0 ;
13+ }else {
14+ days[i] = remain / speeds[i] + 1 ;
15+ }
16+ }
17+ List<Integer > result = new ArrayList<> ();
18+ int preDay = days[0 ];
19+ int count = 1 ;
20+ for (int i = 1 ; i < n; i++ ){
21+ if (days[i] <= preDay){
22+ count++ ;
23+ } else {
24+ result. add(count);
25+ preDay = days[i];
26+ count = 1 ;
27+ }
28+ }
29+
30+ result. add(count);
31+
32+ int [] answer = new int [result. size()];
33+ for (int i = 0 ; i < result. size(); i++ ){
34+ answer[i] = result. get(i);
35+ }
36+
37+
38+
39+ return answer;
40+ }
41+ }
42+
43+ ```
You can’t perform that action at this time.
0 commit comments