1
class Solution {
2
public:
3
vector<int> deckRevealedIncreasing(vector<int> &deck) {
4
int n = deck.size(), idx = 0, idx1 = 0;
5
vector<int> res(n, -1);
6
sort(deck.begin(), deck.end());
7
bool found = 1;
8
while (idx < n) {
9
if (res[idx1] == -1 and found) {
10
res[idx1] = deck[idx];
11
found = 0;
12
idx++;
13
} else if (res[idx1] == -1)
14
found = 1;
15
idx1 = (idx1 + 1) % n;
16
}
17
return res;
18
}
19
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0