1047. Remove All Adjacent Duplicates In String Easy

@problem@discussion
#String#Stack



1/**
2 * [1047] Remove All Adjacent Duplicates In String
3 *
4 * You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them.
5 * We repeatedly make duplicate removals on s until we no longer can.
6 * Return the final string after all such duplicate removals have been made. It can be proven that the answer is unique.
7 *  
8 * Example 1:
9 * 
10 * Input: s = "abbaca"
11 * Output: "ca"
12 * Explanation: 
13 * For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move.  The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca".
14 * 
15 * Example 2:
16 * 
17 * Input: s = "azxxzy"
18 * Output: "ay"
19 * 
20 *  
21 * Constraints:
22 * 
23 * 	1 <= s.length <= 10^5
24 * 	s consists of lowercase English letters.
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/
30// discuss: https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn remove_duplicates(s: String) -> String {
36        String::new()
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_1047() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.