< Summary

Information
Class: LeetCode.Algorithms.RangeSumQueryImmutable.RangeSumQueryImmutableBruteForce
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\RangeSumQueryImmutable\RangeSumQueryImmutableBruteForce.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 42
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
SumRange(...)0%620%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\RangeSumQueryImmutable\RangeSumQueryImmutableBruteForce.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.RangeSumQueryImmutable;
 13
 14/// <inheritdoc />
 15public class RangeSumQueryImmutableBruteForce : IRangeSumQueryImmutable
 16{
 17    private readonly int[] _nums;
 18
 019    public RangeSumQueryImmutableBruteForce(int[] nums)
 020    {
 021        _nums = nums;
 022    }
 23
 24    /// <summary>
 25    ///     Time complexity - O(right − left + 1)
 26    ///     Space complexity - O(1)
 27    /// </summary>
 28    /// <param name="left"></param>
 29    /// <param name="right"></param>
 30    /// <returns></returns>
 31    public int SumRange(int left, int right)
 032    {
 033        var sum = 0;
 34
 035        for (var i = left; i <= right; i++)
 036        {
 037            sum += _nums[i];
 038        }
 39
 040        return sum;
 041    }
 42}