Skip to content

Commit b9ea328

Browse files
authoredApr 13, 2021
Create 950-reveal-cards-in-increasing-order.js
1 parent 97871ed commit b9ea328

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
 
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {number[]} deck
3+
* @return {number[]}
4+
*/
5+
const deckRevealedIncreasing = function(deck) {
6+
const n= deck.length;
7+
8+
deck.sort((a, b) => a - b)
9+
const q = [];
10+
for (let i=0; i<n; i++) q.push(i);
11+
const res = new Array(n).fill(0);
12+
for (let i=0; i<n; i++){
13+
res[q.shift()]=deck[i];
14+
q.push(q.shift());
15+
}
16+
return res;
17+
};

0 commit comments

Comments
 (0)
Please sign in to comment.