Skip to content

Commit 4414c1b

Browse files
author
luzhipeng
committed
feat: 更新每日一题参考答案
1 parent 9167f32 commit 4414c1b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* @lc app=leetcode id=950 lang=javascript
3+
*
4+
* [950] Reveal Cards In Increasing Order
5+
*/
6+
/**
7+
* @param {number[]} deck
8+
* @return {number[]}
9+
*/
10+
var deckRevealedIncreasing = function(deck) {
11+
const hand = [];
12+
const table = deck.sort((a, b) => a - b);
13+
14+
let handTurn = true;
15+
while (table.length > 0) {
16+
if (handTurn) {
17+
hand.unshift(table.pop());
18+
} else {
19+
hand.unshift(hand.pop());
20+
}
21+
handTurn = !handTurn;
22+
}
23+
return hand;
24+
};

0 commit comments

Comments
 (0)