cs: add “2390. Removing Stars From a String”
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
37e383c221
commit
7e9a865db7
1 changed files with 18 additions and 0 deletions
18
cs/removing-stars-from-a-string.cs
Normal file
18
cs/removing-stars-from-a-string.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
public class Solution {
|
||||||
|
public string RemoveStars(string s) {
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (var c in s) {
|
||||||
|
switch (c) {
|
||||||
|
case '*':
|
||||||
|
sb.Remove(sb.Length - 1, 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sb.Append(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue