1
var removeOccurrences = function (s, part) {
2
let stack = [];
3
for (let c of s) {
4
stack.push(c);
5
if (
6
stack.length >= part.length &&
7
stack[stack.length - 1] == part[part.length - 1]
8
) {
9
let temp = [];
10
for (let i = 0; i < part.length; i++) {
11
temp.push(stack.pop());
12
}
13
temp.reverse();
14
if (temp.join("") != part) {
15
for (let c of temp) {
16
stack.push(c);
17
}
18
}
19
}
20
}
21
let ans = [];
22
while (stack.length > 0) {
23
ans.push(stack.pop());
24
}
25
ans.reverse();
26
return ans.join("");
27
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0