< Summary

Information
Class: LeetCode.Algorithms.FirstCompletelyPaintedRowOrColumn.FirstCompletelyPaintedRowOrColumnDictionary
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\FirstCompletelyPaintedRowOrColumn\FirstCompletelyPaintedRowOrColumnDictionary.cs
Line coverage
100%
Covered lines: 29
Uncovered lines: 0
Coverable lines: 29
Total lines: 63
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
FirstCompleteIndex(...)100%1010100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\FirstCompletelyPaintedRowOrColumn\FirstCompletelyPaintedRowOrColumnDictionary.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.FirstCompletelyPaintedRowOrColumn;
 13
 14/// <inheritdoc />
 15public class FirstCompletelyPaintedRowOrColumnDictionary : IFirstCompletelyPaintedRowOrColumn
 16{
 17    /// <summary>
 18    ///     Time complexity - O(m * n)
 19    ///     Space complexity - O(m * n)
 20    /// </summary>
 21    /// <param name="arr"></param>
 22    /// <param name="mat"></param>
 23    /// <returns></returns>
 24    public int FirstCompleteIndex(int[] arr, int[][] mat)
 225    {
 226        var numsDictionary = new Dictionary<int, int>();
 27
 3028        for (var i = 0; i < arr.Length; i++)
 1329        {
 1330            numsDictionary.Add(arr[i], i);
 1331        }
 32
 233        var result = int.MaxValue;
 234        var m = mat.Length;
 235        var n = mat[0].Length;
 36
 1437        for (var i = 0; i < m; i++)
 538        {
 539            var index = int.MinValue;
 40
 3641            for (var j = 0; j < n; j++)
 1342            {
 1343                index = Math.Max(index, numsDictionary[mat[i][j]]);
 1344            }
 45
 546            result = Math.Min(result, index);
 547        }
 48
 1449        for (var i = 0; i < n; i++)
 550        {
 551            var index = int.MinValue;
 52
 3653            for (var j = 0; j < m; j++)
 1354            {
 1355                index = Math.Max(index, numsDictionary[mat[j][i]]);
 1356            }
 57
 558            result = Math.Min(result, index);
 559        }
 60
 261        return result;
 262    }
 63}