Skip to content

Commit baa11ad

Browse files
authored
Merge pull request neetcode-gh#2669 from thisiswhale/patch-6
2 parents 5b083c6 + 9c54b52 commit baa11ad

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var removeStars = function(s) {
2+
if(!s.length) return '';
3+
4+
const result = [];
5+
6+
for(let char of s){
7+
if(char == '*') result.pop()
8+
else result.push(char)
9+
}
10+
return result.join('')
11+
};
12+
// Time Complexity: O(n)
13+
// Space Complexity: O(n)

0 commit comments

Comments
 (0)