< Summary

Information
Class: LeetCode.Algorithms.FinalValueOfVariableAfterPerformingOperations.FinalValueOfVariableAfterPerformingOperationsDictionary
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\FinalValueOfVariableAfterPerformingOperations\FinalValueOfVariableAfterPerformingOperationsDictionary.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 41
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
FinalValueAfterOperations(...)100%22100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\FinalValueOfVariableAfterPerformingOperations\FinalValueOfVariableAfterPerformingOperationsDictionary.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2026 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.FinalValueOfVariableAfterPerformingOperations;
 13
 14/// <inheritdoc />
 15public sealed class FinalValueOfVariableAfterPerformingOperationsDictionary : IFinalValueOfVariableAfterPerformingOperat
 16{
 117    private static readonly Dictionary<string, int> OperationsDictionary = new()
 118    {
 119        { "++X", 1 }, { "X++", 1 }, { "--X", -1 }, { "X--", -1 }
 120    };
 21
 22    /// <summary>
 23    ///     Time complexity - O(n)
 24    ///     Space complexity - O(1)
 25    /// </summary>
 26    /// <param name="operations"></param>
 27    /// <returns></returns>
 28    public int FinalValueAfterOperations(string[] operations)
 329    {
 330        var finalValue = 0;
 31
 2632        for (var i = 0; i < operations.Length; i++)
 1033        {
 1034            var operation = operations[i];
 35
 1036            finalValue += OperationsDictionary[operation];
 1037        }
 38
 339        return finalValue;
 340    }
 41}