We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b028249 commit fc745cbCopy full SHA for fc745cb
1 file changed
LeetCode/stl/1047.Remove_ALL_Adjecent.cpp
@@ -0,0 +1,25 @@
1
+class Solution {
2
+public:
3
+ string removeDuplicates(string s) {
4
+ stack<char>st;
5
+ for(auto ch:s){
6
+ if(st.empty()){
7
+ st.push(ch);
8
+ continue;
9
+ }
10
+ if(st.top() !=ch){
11
12
+ }else{
13
+ st.pop();
14
15
16
+ string new_s ="";
17
+ while(!st.empty()){
18
+ char ch = st.top();
19
+ new_s+=ch;
20
21
22
+ reverse(new_s.begin(),new_s.end());
23
+ return new_s;
24
25
+};
0 commit comments