blob: 0931d7be4d4294e053d89ea3359687e8e6aad1ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
struct Solution;
impl Solution {
pub fn orderly_queue(s: String, k: i32) -> String {
if k == 1 {
let ss = s.chars().chain(s.chars()).collect::<Vec<_>>();
let mut v = ss.windows(s.len()).collect::<Vec<_>>();
v.sort();
v[0].iter().copied().collect()
} else {
let mut v = s.chars().collect::<Vec<_>>();
v.sort();
v.iter().collect()
}
}
}
fn main() {
let s = String::from("cba");
let k = 1;
print!("{}", Solution::orderly_queue(s, k));
}
|