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 | 29 | 30 |
Tags
- c++
- 코딩테스트
- 백준 1103번
- 수학숙제
- 백준 1103번 게임
- 백준 17070번
- 2870번 c++
- Lv.3
- 프로그래머스
- C#
- 유니티
- Beakjoon
- 2468 c++
- 오브젝트 풀링
- 백준 1103번 c++
- Lv2
- 백준 2870번
- 백준 17070번 c++
- Unity
- 2870번 수학숙제
- 코테
- 백준 c++ 2870번
- 플레이어 이동
- 2870번 수학숙제 c++
- 백준
- 백준 c++ 2468번
- Algorithm
- dfs
- 2870번
- 17070번
Archives
- Today
- Total
주녘공부일지
[프로그래머스 C#] Lv.2 기능개발 본문
https://school.programmers.co.kr/learn/courses/30/lessons/42586
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1. 정답코드 및 핵심 아이디어, 유의사항
- 뒤에 있는 기능이 앞에 있는 기능보다 먼저 배포가 가능해도 순서대로 배포
-> 배포까지 걸리는 기간을 Queue에 순서대로 넣고, 맨 앞에 있는 값을 기준으로 지워나가면서 같거나 작은 수는 한번에 배포가 가능함을 체크
https://godgjwnsgur7.tistory.com/46
[C#] 자료구조 정리 (Dict, List, Queue, Stack, HashSet 등)
자료구조(Data Structure)란? 데이터를 효율적으로 접근하고 조작할 수 있게 데이터 구조를 만들어 관리하는 것 - Collections은 C#에서 지원하는 자료구조 클래스 using System.Collections.Generic; 제네릭 컬렉
godgjwnsgur7.tistory.com
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 |