MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / restore_string

Function restore_string

1528-shuffle-string.rs:9–15  ·  view source on GitHub ↗
(s: String, indices: Vec<i32>)

Source from the content-addressed store, hash-verified

7// 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
8
9pub fn restore_string(s: String, indices: Vec<i32>) -> String {
10 let mut res: Vec<char> = vec!['c'; s.len()];
11 for (i, c) in s.chars().enumerate() {
12 res[indices[i as usize] as usize] = c;
13 }
14 res.into_iter().collect()
15}
16
17fn main() {
18 let s = "codeleet".to_string();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected