Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 수학숙제
- 오브젝트 풀링
- 백준 c++ 2468번
- 유니티
- 2468 c++
- 2870번 수학숙제
- Lv2
- 코테
- 백준 1103번 게임
- 플레이어 이동
- Lv.3
- Unity
- 프로그래머스
- 백준 1103번 c++
- 백준
- Beakjoon
- dfs
- 백준 17070번 c++
- 백준 c++ 2870번
- 2870번 수학숙제 c++
- 백준 17070번
- Algorithm
- 코딩테스트
- 백준 1103번
- 백준 2870번
- 2870번
- 17070번
- 2870번 c++
- C#
- c++
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.2 기능개발 본문
https://school.programmers.co.kr/learn/courses/30/lessons/42586
1. 정답코드 및 핵심 아이디어, 유의사항
- 뒤에 있는 기능이 앞에 있는 기능보다 먼저 배포가 가능해도 순서대로 배포
-> 배포까지 걸리는 기간을 Queue에 순서대로 넣고, 맨 앞에 있는 값을 기준으로 지워나가면서 같거나 작은 수는 한번에 배포가 가능함을 체크
https://godgjwnsgur7.tistory.com/46
using System;
using System.Collections.Generic;
public class Solution
{
public int[] solution(int[] progresses, int[] speeds)
{
List<int> answerList = new List<int>();
Queue<int> queue = new Queue<int>();
// 배포까지 걸리는 기간을 queue에 담음
for (int i = 0; i < progresses.Length; i++)
{
int count = 1;
while (progresses[i] + (speeds[i] * count) < 100)
count++;
queue.Enqueue(count);
}
// 배포 가능 체크
while (queue.Count > 0)
{
int count = 1; // 한번에 배포 가능한 개수
int num = queue.Dequeue(); // 배포 가능 체크 기준
// 배포 가능 개수 카운트
while (queue.Count > 0 && queue.Peek() <= num)
{
queue.Dequeue();
count++;
}
answerList.Add(count);
}
return answerList.ToArray();
}
}
'CodingTest > Programmers Lv.2' 카테고리의 다른 글
[프로그래머스 C#] Lv.2 숫자 변환하기 (0) | 2023.09.07 |
---|---|
[프로그래머스 C#] Lv.2 타겟 넘버 (0) | 2023.09.05 |
[프로그래머스 C#] Lv.2 연속된 부분 수열의 합 (0) | 2023.08.30 |
[프로그래머스 C#] Lv.2 연속 부분 수열 합의 개수 (0) | 2023.08.25 |
[프로그래머스 C#] Lv.2 귤 고르기 (0) | 2023.08.25 |