< Summary

Information
Class: LeetCode.Algorithms.LexicographicallyMinimumStringAfterRemovingStars.LexicographicallyMinimumStringAfterRemovingStarsStackBuckets
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\LexicographicallyMinimumStringAfterRemovingStars\LexicographicallyMinimumStringAfterRemovingStarsStackBuckets.cs
Line coverage
92%
Covered lines: 25
Uncovered lines: 2
Coverable lines: 27
Total lines: 65
Line coverage: 92.5%
Branch coverage
90%
Covered branches: 9
Total branches: 10
Branch coverage: 90%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ClearStars(...)90%101092.59%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\LexicographicallyMinimumStringAfterRemovingStars\LexicographicallyMinimumStringAfterRemovingStarsStackBuckets.cs

#LineLine coverage
 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
 12namespace LeetCode.Algorithms.LexicographicallyMinimumStringAfterRemovingStars;
 13
 14/// <inheritdoc />
 15public class LexicographicallyMinimumStringAfterRemovingStarsStackBuckets :
 16    LexicographicallyMinimumStringAfterRemovingStarsBase
 17{
 18    private const int Length = 'z' - 'a' + 1;
 19
 20    /// <summary>
 21    ///     Time complexity - O(n)
 22    ///     Space complexity - O(n)
 23    /// </summary>
 24    /// <param name="s"></param>
 25    /// <returns></returns>
 26    public override string ClearStars(string s)
 227    {
 228        var indexesStacks = new Stack<int>[Length];
 29
 10830        for (var i = 0; i < indexesStacks.Length; i++)
 5231        {
 5232            indexesStacks[i] = new Stack<int>();
 5233        }
 34
 235        var chars = s.ToCharArray();
 36
 2037        for (var i = 0; i < chars.Length; i++)
 838        {
 839            var c = chars[i];
 40
 841            if (c == '*')
 142            {
 443                foreach (var indexesStack in indexesStacks)
 144                {
 145                    if (indexesStack.Count == 0)
 046                    {
 047                        continue;
 48                    }
 49
 150                    var indexToRemove = indexesStack.Pop();
 51
 152                    chars[indexToRemove] = '*';
 53
 154                    break;
 55                }
 156            }
 57            else
 758            {
 759                indexesStacks[c - 'a'].Push(i);
 760            }
 861        }
 62
 263        return BuildResult(chars);
 264    }
 65}

Methods/Properties

ClearStars(System.String)