Skip to content

Commit 621170a

Browse files
committed
Runtime: 1 ms (Top 71.43%) | Memory: 2.10 MB (Top 71.43%)
1 parent 11b1139 commit 621170a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)