Skip to content

Commit 650260a

Browse files
committed
src/bin/lexicographical-numbers.rs
1 parent 0de6f5f commit 650260a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/bin/lexicographical-numbers.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
fn main() {}
2+
3+
struct Solution;
4+
5+
impl Solution {
6+
pub fn lexical_order(n: i32) -> Vec<i32> {
7+
let mut s = (1..=n)
8+
.into_iter()
9+
.map(|x| x.to_string())
10+
.collect::<Vec<String>>();
11+
12+
s.sort();
13+
14+
s.into_iter().map(|x| x.parse::<i32>().unwrap()).collect::<Vec<i32>>()
15+
}
16+
}

0 commit comments

Comments
 (0)