<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let removeDuplicates = function (s) {
let stack = [];
for (v of s) {
let prev = stack.pop();
if (prev != v) {
stack.push(prev);
stack.push(v);
}
}
return stack.join("");
};
console.log(removeDuplicates("abbaca"));
</script>
</body>
</html>
【LeetCode】1047
最新推荐文章于 2024-07-21 15:36:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)