< Summary

Information
Class: LeetCode.Algorithms.RotatingTheBox.RotatingTheBoxMatrix
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\RotatingTheBox\RotatingTheBoxMatrix.cs
Line coverage
100%
Covered lines: 31
Uncovered lines: 0
Coverable lines: 31
Total lines: 65
Line coverage: 100%
Branch coverage
100%
Covered branches: 14
Total branches: 14
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
RotateTheBox(...)100%1414100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\RotatingTheBox\RotatingTheBoxMatrix.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.RotatingTheBox;
 13
 14/// <inheritdoc />
 15public class RotatingTheBoxMatrix : IRotatingTheBox
 16{
 17    /// <summary>
 18    ///     Time complexity - O(n * m)
 19    ///     Space complexity - O(n * m)
 20    /// </summary>
 21    /// <param name="box"></param>
 22    /// <returns></returns>
 23    public char[][] RotateTheBox(char[][] box)
 324    {
 325        var m = box.Length;
 326        var n = box[0].Length;
 27
 328        var result = new char[n][];
 29
 3230        for (var i = 0; i < n; i++)
 1331        {
 1332            result[i] = new char[m];
 1333        }
 34
 1835        for (var i = 0; i < m; i++)
 636        {
 7037            for (var j = 0; j < n; j++)
 2938            {
 2939                result[j][m - i - 1] = box[i][j];
 2940            }
 641        }
 42
 1843        for (var j = 0; j < m; j++)
 644        {
 645            var emptyRow = n - 1;
 46
 7047            for (var i = n - 1; i >= 0; i--)
 2948            {
 2949                switch (result[i][j])
 50                {
 51                    case '#':
 1452                        result[i][j] = '.';
 1453                        result[emptyRow][j] = '#';
 1454                        emptyRow--;
 1455                        break;
 56                    case '*':
 557                        emptyRow = i - 1;
 558                        break;
 59                }
 2960            }
 661        }
 62
 363        return result;
 364    }
 65}

Methods/Properties

RotateTheBox(System.Char[][])