티스토리 뷰
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import java.util.*;
class Solution {
public int[] solution(int[] progresses, int[] speeds) {
Queue<Integer> q = new LinkedList<>();
List<Integer> list = new ArrayList<>();
int length = progresses.length;
for (int i = 0; i < length; i++) {
int sum = progresses[i];
int day = 0;
while (sum < 100) {
sum += speeds[i];
day++;
}
q.offer(day);
}
Integer now = q.poll();
int cnt = 1;
while (!q.isEmpty()) {
if (q.peek() <= now) {
cnt++;
q.poll();
} else {
list.add(cnt);
now = q.poll();
cnt = 1;
}
if (q.isEmpty()) list.add(cnt);
}
int[] ans = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
ans[i] = list.get(i);
}
return ans;
}
}
|
cs |
'PS > programmers' 카테고리의 다른 글
Level2) 전화번호 목록 (0) | 2021.01.08 |
---|---|
Level2)가장 큰 수 (0) | 2020.11.10 |
Level2) 다리를 지나는 트럭 (0) | 2020.10.11 |
Level2) 주식가격 (0) | 2020.10.09 |
Level2) 프린터 (0) | 2020.10.09 |
링크
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- http
- 김영한 JPA
- java
- 이펙티브자바 아이템60
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- js api
- Spring Security
- 김영한 http
- 이펙티브자바 스터디
- js promise
- HTTP 완벽 가이드
- JPA 연관관계 매핑
- 이펙티브자바
- HTTP 완벽가이드
- BOJ
- 이펙티브자바 아이템59
- GCP
- 패스트캠퍼스 컴퓨터공학 완주반
- ㅇㄷㅇㅈ
- 백기선 스터디
- 프로그래머스
- js array
- dreamcoding
- 백준
- REST API
- 모던자바스크립트
- 드림코딩
- 킹수빈닷컴
- JS 딥다이브
- 프로그래머스 SQL
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함