cs: add “2390. Removing Stars From a String”

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2024-01-07 21:03:07 +01:00
parent 37e383c221
commit 7e9a865db7
Signed by: mfocko
GPG key ID: 7C47D46246790496

View 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();
}
}