< Summary

Information
Class: LeetCode.Algorithms.CrawlerLogFolder.CrawlerLogFolderSimulation
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CrawlerLogFolder\CrawlerLogFolderSimulation.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 47
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
MinOperations(...)100%66100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CrawlerLogFolder\CrawlerLogFolderSimulation.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.CrawlerLogFolder;
 13
 14/// <inheritdoc />
 15public class CrawlerLogFolderSimulation : ICrawlerLogFolder
 16{
 17    private const string MoveToParent = "../";
 18    private const string Remain = "./";
 19
 20    /// <summary>
 21    ///     Time complexity - O(n)
 22    ///     Space complexity - O(1)
 23    /// </summary>
 24    /// <param name="logs"></param>
 25    /// <returns></returns>
 26    public int MinOperations(string[] logs)
 327    {
 328        var depth = 0;
 29
 3930        foreach (var log in logs)
 1531        {
 1532            switch (log)
 33            {
 34                case MoveToParent:
 535                    depth = Math.Max(0, depth - 1);
 536                    break;
 37                case Remain:
 238                    break;
 39                default:
 840                    depth++;
 841                    break;
 42            }
 1543        }
 44
 345        return depth;
 346    }
 47}

Methods/Properties

MinOperations(System.String[])