We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7f79c9b commit b1cb0c0Copy full SHA for b1cb0c0
java/0950-reveal-cards-in-increasing-order.java
@@ -0,0 +1,18 @@
1
+class Solution {
2
+ public int[] deckRevealedIncreasing(int[] deck) {
3
+ Arrays.sort(deck);
4
+ int[] res = new int[deck.length];
5
+ ArrayDeque<Integer> q = new ArrayDeque<>();
6
+ for (int i = 0; i < deck.length; i++) {
7
+ q.addLast(i);
8
+ }
9
+ for (int n : deck) {
10
+ int i = q.removeFirst();
11
+ res[i] = n;
12
+ if (!q.isEmpty()) {
13
+ q.addLast(q.removeFirst());
14
15
16
+ return res;
17
18
+}
0 commit comments