Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf52d0d2

Browse files
authored
Merge pull requestneetcode-gh#3222 from nithin1shastry/main
Create: 2390-removing-stars-from-a-string.cpp
2 parents9a1bef9 +a727f80 commitf52d0d2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
classSolution {
2+
public:
3+
stringremoveStars(string s) {
4+
stack<char> stk;
5+
for(int i=0;i<s.size();i++){
6+
if(s[i]=='*'){
7+
stk.pop();
8+
}else stk.push(s[i]);
9+
}
10+
string res ="";
11+
while(!stk.empty()){
12+
res += stk.top();
13+
stk.pop();
14+
}
15+
reverse(res.begin(), res.end());
16+
return res;
17+
}
18+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp