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 11b1139 commit 621170aCopy full SHA for 621170a
scripts/algorithms/R/Reveal Cards In Increasing Order/Reveal Cards In Increasing Order.rs
@@ -0,0 +1,18 @@
1
+// Runtime: 1 ms (Top 71.43%) | Memory: 2.10 MB (Top 71.43%)
2
+
3
+impl Solution {
4
+ pub fn deck_revealed_increasing(deck: Vec<i32>) -> Vec<i32> {
5
+ use std::collections::VecDeque;
6
+ let mut deck = deck;
7
+ deck.sort();
8
+ let mut solution: VecDeque<i32> = VecDeque::new();
9
+ deck.iter().rev().for_each(|v| {
10
+ solution.push_front(*v);
11
+ let temp = solution.pop_back().unwrap();
12
+ solution.push_front(temp);
13
+ });
14
+ let temp = solution.pop_front().unwrap();
15
+ solution.push_back(temp);
16
+ Vec::from(solution)
17
+ }
18
+}
0 commit comments