class Solution {
public:
vector<int> deckRevealedIncreasing(vector<int>& deck) {
sort(deck.rbegin(),deck.rend());
deque<int> dq;
dq.push_back(deck[0]);
for(int i = 1;i < deck.size();i++)
{
dq.push_front(dq.back());
dq.pop_back();
dq.push_front(deck[i]);
}
vector<int> res(dq.begin(),dq.end());
return res;
}
};
运行效率:
Runtime: 4 ms, faster than 88.98% of C++ online submissions for Reveal Cards In Increasing Order.
Memory Usage: 8.5 MB, less than 75.29% of C++ online submissions for Reveal Cards In Increasing Order.