일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- cpp
- EOI
- 온라인석사
- 딥러닝
- Plotting
- machine learning
- 방통대
- 위니펙
- mpnp
- 알고리즘
- LAA
- MATLAB
- 프로그래머스
- LV1
- 캐나다 영주권
- 주정부이민
- C++
- 조지아텍
- 머신러닝
- Deep learning
- 매트랩
- 컴퓨터과학과
- 선형대수
- 코딩테스트
- leetcode
- 기본
- 방송통신대학교
- zeros
- omscs
- 개발자
Archives
- Today
- Total
Byte by Byte
950. Reveal Cards In Increasing Order.cpp 본문
double ended queue 활용. 매우 유용한 stl.
class Solution {
public:
vector<int> deckRevealedIncreasing(vector<int>& deck) {
vector<int>res;
deque<int>tmp;
sort(deck.begin(),deck.end(),greater<int>());
for(int i =0; i<deck.size(); i++){
if(i==0) {
tmp.push_back(deck[i]);
}
else{
tmp.push_front(tmp[tmp.size()-1]);
tmp.pop_back();
tmp.push_front(deck[i]);
}
// cout<< i << "th : ";
// for(auto K : tmp) cout<< K << " ";
// cout << endl;
}
for(auto k : tmp){
res.push_back(k);
}
return res;
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
890. Find and Replace Pattern.cpp (0) | 2021.10.07 |
---|---|
1079. Letter Tile Possibilities.cpp (0) | 2021.10.07 |
921. Minimum Add to Make Parentheses Valid.cpp (0) | 2021.10.07 |
1557. Minimum Number of Vertices to Reach All Nodes.cpp (0) | 2021.10.07 |
1941. Check if All Characters Have Equal Number of Occurrences.cpp (0) | 2021.10.07 |