Skip to content

Commit 9f0d820

Browse files
authored
Merge pull request #3669 from NotADucc/2390
create 2390-removing-stars-from-a-string.cs
2 parents fd1d112 + 38d774e commit 9f0d820

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class Solution
2+
{
3+
public string RemoveStars(string s)
4+
{
5+
var output = new StringBuilder(s.Length);
6+
7+
foreach (var ch in s)
8+
{
9+
if (ch == '*')
10+
{
11+
output.Length--;
12+
}
13+
else
14+
{
15+
output.Append(ch);
16+
}
17+
}
18+
19+
return output.ToString();
20+
}
21+
}

0 commit comments

Comments
 (0)