< Summary

Information
Class: LeetCode.Algorithms.ConvertIntegerToTheSumOfTwoNoZeroIntegers.ConvertIntegerToTheSumOfTwoNoZeroIntegersBruteForce
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\ConvertIntegerToTheSumOfTwoNoZeroIntegers\ConvertIntegerToTheSumOfTwoNoZeroIntegersBruteForce.cs
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 54
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetNoZeroIntegers(...)100%66100%
IsNoZero(...)100%44100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\ConvertIntegerToTheSumOfTwoNoZeroIntegers\ConvertIntegerToTheSumOfTwoNoZeroIntegersBruteForce.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.ConvertIntegerToTheSumOfTwoNoZeroIntegers;
 13
 14/// <inheritdoc />
 15public sealed class ConvertIntegerToTheSumOfTwoNoZeroIntegersBruteForce : IConvertIntegerToTheSumOfTwoNoZeroIntegers
 16{
 17    /// <summary>
 18    ///     Time complexity - O(n log n)
 19    ///     Space complexity - O(1)
 20    /// </summary>
 21    /// <param name="n"></param>
 22    /// <returns></returns>
 23    public int[] GetNoZeroIntegers(int n)
 724    {
 725        var a = 1;
 26
 1927        while (a < n)
 1928        {
 1929            if (IsNoZero(a) && IsNoZero(n - a))
 730            {
 731                break;
 32            }
 33
 1234            a++;
 1235        }
 36
 737        return [a, n - a];
 738    }
 39
 40    private static bool IsNoZero(int x)
 3741    {
 8142        while (x > 0)
 5643        {
 5644            if (x % 10 == 0)
 1245            {
 1246                return false;
 47            }
 48
 4449            x /= 10;
 4450        }
 51
 2552        return true;
 3753    }
 54}