Notice
Recent Posts
Recent Comments
- Today
- Total
01-11 05:49
Tags
- BFS
- leetcode
- array
- Algorithm
- ์๋ฐ
- database
- ์๋ฐ์์ ์
- ๋ฐฑ์ค
- ํ๋ก๊ทธ๋๋จธ์ค
- spring
- java
- ๋ฌธ๋ฒ
- CS
- OOP
- MST
- pytorch
- dp
- Graph
- ๋ค์ต์คํธ๋ผ
- ๊ทธ๋ฆฌ๋
- ๊ตฌํ
- ์ธํด
- tree
- ๋ฒจ๋งํฌ๋
- ์กธ์ ์ํ
- ์์์ ๋ ฌ
- ์๋ฃ๊ตฌ์กฐ
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- PS
- ๋ฐฑ์๋
Link
Partially Committed
[ํ] ๊ธฐ๋ฅ๊ฐ๋ฐ (JAVA) ๋ณธ๋ฌธ
728x90
๋ฐ์ํ
SMALL
https://school.programmers.co.kr/learn/courses/30/lessons/42586?language=java
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
class Solution {
public int[] solution(int[] progresses, int[] speeds) throws IOException {
ArrayList<Integer> answer = new ArrayList<>();
ArrayList<Integer> arr = new ArrayList<>();
Queue<Integer> q = new LinkedList<>();
int task = 0;
for (int i = 0; i < progresses.length; i++) {
task = (int) Math.ceil(((100 - progresses[i]) / (double) speeds[i]));
q.add(task);
}
while (!q.isEmpty()) {
int cnt = 1;
int day = q.poll();
while (!q.isEmpty() && day >= q.peek()) {
cnt++;
q.poll();
}
answer.add(cnt);
}
return answer.stream().mapToInt(Integer::intValue).toArray();
}
}
728x90
๋ฐ์ํ
LIST
'๐ฅ Algorithm || ๋ฌธ์ ํ์ด > PS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[CH01] ๊ตฌ๊ฐํฉ (0) | 2022.09.09 |
---|---|
[์ฐ์ ์์ํ] ํ๋ฆฐํฐ (์๋ฐ) (0) | 2022.09.04 |
[์คํ/ํ] ์ฌ๋ฐ๋ฅธ ๊ดํธ (JAVA) (0) | 2022.09.03 |
[๋ฐฐ์ด] ๊ฐ์ ์ซ์๋ ์ซ์ด (JAVA) (0) | 2022.09.02 |
[์ ๋ ฌ] ๊ฐ์ฅ ํฐ ์ (JAVA) (0) | 2022.09.02 |
Comments