Skip to content

Commit 0bb4223

Browse files
committed
添加1047. 删除字符串中的所有相邻重复项javaScript版本
1 parent 64b9363 commit 0bb4223

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

problems/1047.删除字符串中的所有相邻重复项.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ class Solution:
186186

187187
Go:
188188

189+
javaScript:
190+
191+
```js
192+
/**
193+
* @param {string} s
194+
* @return {string}
195+
*/
196+
var removeDuplicates = function(s) {
197+
const stack = [];
198+
for(const x of s) {
199+
let c = null;
200+
if(stack.length && x === (c = stack.pop())) continue;
201+
c && stack.push(c);
202+
stack.push(x);
203+
}
204+
return stack.join("");
205+
};
206+
```
189207

190208

191209

0 commit comments

Comments
 (0)