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
- UnrealMP
- 백준
- 백준 1253번
- C++
- FBX
- 데이터베이스 배움터
- Linux
- oracle
- 언리얼 플러그인
- 실습
- 1253번
- 비재귀셰그먼트
- 트랜잭션 관리
- command not found
- UActor
- hackerank
- 셰그먼트트리
- 의미와 무의미의 경계에서
- 1967번
- OS
- 1759번
- SQL
- 2단계로킹
- 민겸수
- objtofbx
- 오손데이터읽기
- Unreal
- 5639
- Security
- 언리얼 커스텀 플러그인
Archives
- Today
- Total
fatalite
C++ 주식 가격 [고득점 Kit 스택 / 큐] 본문
Problem
난이도: 프로그래머스 2단계
분류: 스택이라는데,, set과 pair 써서 풀었다.
for문쓰면서 erase 할 생각하지말자. 이럴거면 vector써도 똑같았을듯?
아무튼 list를 두자는 아이디어는 괜찮았던듯.
Solution
#include <string>
#include <vector>
#include <iostream>
#include <set>
using namespace std;
vector<int> solution(vector<int> prices) {
vector<int> answer;
set<pair<int,int>> List;
answer.resize(prices.size(),0);
for(int i = 0; i < prices.size()-1; i++){
List.insert({i, prices[i]});
set<pair<int,int>> ListCopy = List;
for(pair<int,int> p : ListCopy){
if(p.second <= prices[i]){
answer[p.first]++;
}else{
List.erase(p);
}
}
}
return answer;
}
'코딩 인터뷰 > 프로그래머스' 카테고리의 다른 글
사칙 연산 - 프로그래머스 (0) | 2023.10.15 |
---|---|
등굣길 - 프로그래머스 (0) | 2023.10.15 |
C++ 다리를 지나는 트럭 [고득점 Kit 스택 / 큐] (0) | 2023.05.13 |
C++ 프로세스 [고득점 Kit 스택 / 큐] (0) | 2023.05.13 |
C++ 같은 숫자는 싫어 [스택] (0) | 2023.05.13 |