[프로그래머스 C++] 프로세스
[프로그래머스 C++] 프로세스
https://school.programmers.co.kr/learn/courses/30/lessons/42587
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
해결전략
Queue 큐, Priority_Queue 우선순위 큐
코드
#include <string> #include <vector> #include <queue> using namespace std; int solution(vector<int> priorities, int location) { queue<pair<int,int>> Q; priority_queue<int> pQ; for (int i = 0; i < priorities.size(); i++) { Q.push({priorities[i], i}); pQ.push(priorities[i]); } int answer = 1; while(!Q.empty()) { if(Q.front().first == pQ.top()) { if (Q.front().second == location) { return answer; } Q.pop(); pQ.pop(); answer++; } else { pair<int,int> tmp = Q.front(); Q.pop(); Q.push(tmp); } } return answer; }
'⭐ 코딩테스트 > 프로그래머스' 카테고리의 다른 글
[프로그래머스 C++] 타겟 넘버 (0) | 2023.09.26 |
---|---|
[프로그래머스 C++] 타겟 넘버 (0) | 2023.09.25 |
[프로그래머스 C++] 기능개발 (0) | 2023.09.22 |
[프로그래머스 C++] [1차] 뉴스 클러스터링 (0) | 2023.09.21 |
[프로그래머스 C++] 튜플 (0) | 2023.09.19 |
댓글
이 글 공유하기
다른 글
-
[프로그래머스 C++] 타겟 넘버
[프로그래머스 C++] 타겟 넘버
2023.09.26 -
[프로그래머스 C++] 타겟 넘버
[프로그래머스 C++] 타겟 넘버
2023.09.25 -
[프로그래머스 C++] 기능개발
[프로그래머스 C++] 기능개발
2023.09.22 -
[프로그래머스 C++] [1차] 뉴스 클러스터링
[프로그래머스 C++] [1차] 뉴스 클러스터링
2023.09.21
댓글을 사용할 수 없습니다.