Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = "the quick (brown (fox) jumps) over"
- (f, t) = (18, 21)
- ss = s[:f] + s[t-1:f-1:-1] + s[t:]
- let s = String::from("the quick (brown (fox) jumps) over");
- let sc: Vec<_> = s.chars().collect();
- let (f, t) = (18, 21); // result of searching through sc
- let mut new_s: Vec<_> = sc[..f].into_iter().collect();
- new_s.extend(&sc[f..t].into_iter().rev().collect::<Vec<_>>());
- new_s.extend(&sc[t..].into_iter().collect::<Vec<_>>());
- let mut ss = String::with_capacity(new_s.len());
- for c in new_s.iter() {ss.push(**c);}
Add Comment
Please, Sign In to add comment