< Summary

Information
Class: LeetCode.Algorithms.CountSpecialTriplets.CountSpecialTripletsBruteForce
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CountSpecialTriplets\CountSpecialTripletsBruteForce.cs
Line coverage
89%
Covered lines: 25
Uncovered lines: 3
Coverable lines: 28
Total lines: 65
Line coverage: 89.2%
Branch coverage
91%
Covered branches: 11
Total branches: 12
Branch coverage: 91.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
SpecialTriplets(...)91.66%121289.28%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CountSpecialTriplets\CountSpecialTripletsBruteForce.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.CountSpecialTriplets;
 13
 14/// <inheritdoc />
 15public sealed class CountSpecialTripletsBruteForce : ICountSpecialTriplets
 16{
 17    private const int Modulo = 1_000_000_007;
 18
 19    /// <summary>
 20    ///     Time complexity - O(n^3)
 21    ///     Space complexity - O(1)
 22    /// </summary>
 23    /// <param name="nums"></param>
 24    /// <returns></returns>
 25    public int SpecialTriplets(int[] nums)
 326    {
 327        long result = 0;
 28
 329        var numsLength = nums.Length;
 30
 1831        for (var i = 0; i < numsLength - 2; i++)
 632        {
 633            var a = nums[i];
 34
 3235            for (var j = i + 1; j < numsLength - 1; j++)
 1036            {
 1037                var b = nums[j] * 2;
 38
 1039                if (a != b)
 640                {
 641                    continue;
 42                }
 43
 2244                for (var k = j + 1; k < numsLength; k++)
 745                {
 746                    var c = nums[k];
 47
 748                    if (b != c)
 349                    {
 350                        continue;
 51                    }
 52
 453                    result++;
 54
 455                    if (result == Modulo)
 056                    {
 057                        result = 0;
 058                    }
 459                }
 460            }
 661        }
 62
 363        return (int)result;
 364    }
 65}

Methods/Properties

SpecialTriplets(System.Int32[])