< Summary

Information
Class: LeetCode.Algorithms.SetMatrixZeroes.SetMatrixZeroesArrayMarkers
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\SetMatrixZeroes\SetMatrixZeroesArrayMarkers.cs
Line coverage
100%
Covered lines: 35
Uncovered lines: 0
Coverable lines: 35
Total lines: 67
Line coverage: 100%
Branch coverage
100%
Covered branches: 18
Total branches: 18
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
SetZeroes(...)100%1818100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\SetMatrixZeroes\SetMatrixZeroesArrayMarkers.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.SetMatrixZeroes;
 13
 14/// <inheritdoc />
 15public class SetMatrixZeroesArrayMarkers : ISetMatrixZeroes
 16{
 17    /// <summary>
 18    ///     Time complexity - O(m * n)
 19    ///     Space complexity - O(m + n)
 20    /// </summary>
 21    /// <param name="matrix"></param>
 22    public void SetZeroes(int[][] matrix)
 223    {
 224        var rows = new bool[matrix.Length];
 225        var columns = new bool[matrix[0].Length];
 26
 1627        for (var i = 0; i < matrix.Length; i++)
 628        {
 5429            for (var j = 0; j < matrix[i].Length; j++)
 2130            {
 2131                if (matrix[i][j] != 0)
 1832                {
 1833                    continue;
 34                }
 35
 336                rows[i] = true;
 337                columns[j] = true;
 338            }
 639        }
 40
 1641        for (var i = 0; i < rows.Length; i++)
 642        {
 643            if (!rows[i])
 444            {
 445                continue;
 46            }
 47
 1848            for (var j = 0; j < columns.Length; j++)
 749            {
 750                matrix[i][j] = 0;
 751            }
 252        }
 53
 1854        for (var i = 0; i < columns.Length; i++)
 755        {
 756            if (!columns[i])
 457            {
 458                continue;
 59            }
 60
 2461            for (var j = 0; j < rows.Length; j++)
 962            {
 963                matrix[j][i] = 0;
 964            }
 365        }
 266    }
 67}

Methods/Properties

SetZeroes(System.Int32[][])