< Summary

Information
Class: LeetCode.Algorithms.GoalParserInterpretation.GoalParserInterpretationStringBuilder
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\GoalParserInterpretation\GoalParserInterpretationStringBuilder.cs
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 56
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Interpret(...)100%88100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\GoalParserInterpretation\GoalParserInterpretationStringBuilder.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
 12using System.Text;
 13
 14namespace LeetCode.Algorithms.GoalParserInterpretation;
 15
 16/// <inheritdoc />
 17public class GoalParserInterpretationStringBuilder : IGoalParserInterpretation
 18{
 19    /// <summary>
 20    ///     Time complexity - O(n)
 21    ///     Space complexity - O(n)
 22    /// </summary>
 23    /// <param name="command"></param>
 24    /// <returns></returns>
 25    public string Interpret(string command)
 326    {
 327        var stringBuilder = new StringBuilder();
 28
 3629        for (var i = 0; i < command.Length; i++)
 1530        {
 1531            if (i < command.Length - 1)
 1432            {
 1433                switch (command[i])
 34                {
 1135                    case '(' when command[i + 1] == ')':
 736                        stringBuilder.Append('o');
 737                        i++;
 738                        break;
 39                    case '(':
 440                        stringBuilder.Append("al");
 441                        i += 3;
 442                        break;
 43                    default:
 344                        stringBuilder.Append(command[i]);
 345                        break;
 46                }
 1447            }
 48            else
 149            {
 150                stringBuilder.Append(command[i]);
 151            }
 1552        }
 53
 354        return stringBuilder.ToString();
 355    }
 56}

Methods/Properties

Interpret(System.String)