Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let input = std::env::args().skip(1).next().unwrap();
- let mut stack = Vec::with_capacity(input.len() / 4);
- for ch in input.chars() {
- match (ch, stack.last()) {
- ('}', Some(&'{')) | (']', Some(&'[')) | (')', Some(&'(')) => {
- stack.pop();
- }
- _ => stack.push(ch),
- }
- }
- let output: String = stack.iter().collect();
- println!("{}", output);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement