From 38d774ea05c70c5d964a65747c2b2938255b4d7d Mon Sep 17 00:00:00 2001 From: Guillaume Desktop Date: Fri, 11 Oct 2024 21:58:29 +0200 Subject: [PATCH] create 2390-removing-stars-from-a-string.cs --- csharp/2390-removing-stars-from-a-string.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 csharp/2390-removing-stars-from-a-string.cs diff --git a/csharp/2390-removing-stars-from-a-string.cs b/csharp/2390-removing-stars-from-a-string.cs new file mode 100644 index 000000000..f3204ca16 --- /dev/null +++ b/csharp/2390-removing-stars-from-a-string.cs @@ -0,0 +1,21 @@ +public class Solution +{ + public string RemoveStars(string s) + { + var output = new StringBuilder(s.Length); + + foreach (var ch in s) + { + if (ch == '*') + { + output.Length--; + } + else + { + output.Append(ch); + } + } + + return output.ToString(); + } +} \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy