leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0950.cpp (558B)
0 class Solution {
1 public:
2 vector<int> deckRevealedIncreasing(vector<int> &deck) {
3 sort(deck.begin(), deck.end(), [](const int a, const int b) { return a > b; });
4 deque<int> q;
5 vector<int> res;
7 for (int i = 0; i < deck.size() - 1; i++) {
8 q.push_back(deck[i]);
9 q.push_back(q.front());
10 q.pop_front();
11 }
12 q.push_back(deck[deck.size() - 1]);
14 while (!q.empty()) {
15 res.push_back(q.back());
16 q.pop_back();
17 }
18 return res;
19 }
20 };