2019-11-10 LeetCode in Rust LeetCode 1047. Remove All Adjacent Duplicates In String Problem Statement impl Solution { pub fn remove_duplicates(s: String) -> String { let mut stack = vec![]; let mut ans = "".to_string(); for c in s.chars() { if stack.is_empty() || c != *stack.get(stack.len() - 1).unwrap() { stack.push(c); continue; } if c == *stack.get(stack.len() - 1).unwrap() { stack.pop(); } } while !stack.is_empty() { ans.push(stack.pop().unwrap()); } return ans.chars().rev().collect::<String>(); }} Newer LeetCode 1043. Partition Array for Maximum Sum Older LeetCode 1048. Longest String Chain