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 0de6f5f commit 650260aCopy full SHA for 650260a
src/bin/lexicographical-numbers.rs
@@ -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