| | 1 | | // -------------------------------------------------------------------------------- |
| | 2 | | // Copyright (C) 2025 Eugene Eremeev (also known as Yevhenii Yeriemeieiv). |
| | 3 | | // All Rights Reserved. |
| | 4 | | // -------------------------------------------------------------------------------- |
| | 5 | | // This software is the confidential and proprietary information of Eugene Eremeev |
| | 6 | | // (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not |
| | 7 | | // disclose such Confidential Information and shall use it only in accordance with |
| | 8 | | // the terms of the license agreement you entered into with Eugene Eremeev (also |
| | 9 | | // known as Yevhenii Yeriemeieiv). |
| | 10 | | // -------------------------------------------------------------------------------- |
| | 11 | |
|
| | 12 | | namespace LeetCode.Algorithms.LexicographicallyMinimumStringAfterRemovingStars; |
| | 13 | |
|
| | 14 | | public abstract class LexicographicallyMinimumStringAfterRemovingStarsBase : |
| | 15 | | ILexicographicallyMinimumStringAfterRemovingStars |
| | 16 | | { |
| | 17 | | public abstract string ClearStars(string s); |
| | 18 | |
|
| | 19 | | protected static string BuildResult(char[] chars) |
| 6 | 20 | | { |
| 6 | 21 | | var lastLetterIndex = 0; |
| | 22 | |
|
| 60 | 23 | | for (var i = 0; i < chars.Length; i++) |
| 24 | 24 | | { |
| 24 | 25 | | if (chars[i] == '*') |
| 6 | 26 | | { |
| 6 | 27 | | continue; |
| | 28 | | } |
| | 29 | |
|
| 18 | 30 | | chars[lastLetterIndex] = chars[i]; |
| | 31 | |
|
| 18 | 32 | | lastLetterIndex++; |
| 18 | 33 | | } |
| | 34 | |
|
| 6 | 35 | | return new string(chars, 0, lastLetterIndex); |
| 6 | 36 | | } |
| | 37 | | } |