Skip to content

Commit 98c9294

Browse files
committed
✅ [2390]
1 parent 2b4cc17 commit 98c9294

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

2390/my_solution.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @param {string} s
3+
* @return {string}
4+
*/
5+
var removeStars = function (s) {
6+
let result = []
7+
for (let i = 0; i < s.length; i++) {
8+
if (s[i] === "*") {
9+
result.pop();
10+
} else {
11+
result.push(s[i])
12+
}
13+
}
14+
15+
return result.join("")
16+
};
17+
18+
19+
let x =
20+
// removeStars("erase*****")
21+
removeStars("leet**cod*e")
22+
23+
console.log("Es")
24+
console.log(x)

2390/solution.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string} s
3+
* @return {string}
4+
*/
5+
var removeStars = function (s) {
6+
let result = []
7+
for (let i = 0; i < s.length; i++) {
8+
if (s[i] === "*") {
9+
result.pop();
10+
} else {
11+
result.push(s[i])
12+
}
13+
}
14+
15+
return result.join("")
16+
};

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
- [2215. Find the Difference of Two Arrays](./2215/)
125125
- [2352. Equal Row and Column Pairs](./2352/)
126126
- [2373. Largest Local Values in a Matrix](./2373/)
127+
- [2390. Removing Stars From a String](./2390/)
127128
- [2448. Minimum Cost to Make Array Equal](./2448/)
128129

129130
---
@@ -172,7 +173,7 @@ Batch create:
172173
NOTE: JS IS HERE
173174
-->
174175
```ssh
175-
chapter=2352 && mkdir ./$chapter && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js && alias x="node ./$chapter/my_solution.js"
176+
chapter=2390 && mkdir ./$chapter && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js && alias x="node ./$chapter/my_solution.js"
176177
```
177178
> then you can use `x` for quick debug.
178179

0 commit comments

Comments
 (0)