We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8b03796 commit ba481c4Copy full SHA for ba481c4
solution/0950.Reveal Cards In Increasing Order/Solution.cpp
@@ -0,0 +1,33 @@
1
+class Solution {
2
+public:
3
+ vector<int> deckRevealedIncreasing(vector<int>& deck) {
4
+ if (deck.size() == 0)
5
+ return {} ;
6
+
7
+ sort(deck.begin(), deck.end()) ;
8
+ int len = deck.size() ;
9
10
+ int flg = deck.at(0)-1 ;
11
+ vector<int > o(len, flg) ;
12
13
+ int i = 0, p = 0;
14
+ for ( ; ;)
15
+ {
16
+ o[p] = deck.at(i) ;
17
18
+ if (++i < len)
19
20
+ do {
21
+ p = (p+1)%len ;
22
+ } while (o.at(p) != flg) ;
23
24
25
26
+ }
27
+ else
28
+ break ;
29
30
31
+ return o ;
32
33
+};
0 commit comments