< Summary

Information
Class: LeetCode.Algorithms.RobotReturnToOrigin.RobotReturnToOriginSimulation
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\RobotReturnToOrigin\RobotReturnToOriginSimulation.cs
Line coverage
88%
Covered lines: 15
Uncovered lines: 2
Coverable lines: 17
Total lines: 50
Line coverage: 88.2%
Branch coverage
92%
Covered branches: 13
Total branches: 14
Branch coverage: 92.8%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
JudgeCircle(...)92.85%141488.23%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\RobotReturnToOrigin\RobotReturnToOriginSimulation.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.RobotReturnToOrigin;
 13
 14/// <inheritdoc />
 15public class RobotReturnToOriginSimulation : IRobotReturnToOrigin
 16{
 17    /// <summary>
 18    ///     Time complexity - O(n)
 19    ///     Space complexity - O(1)
 20    /// </summary>
 21    /// <param name="moves"></param>
 22    /// <returns></returns>
 23    public bool JudgeCircle(string moves)
 224    {
 225        var x = 0;
 226        var y = 0;
 27
 1428        foreach (var move in moves)
 429        {
 430            switch (move)
 31            {
 32                case 'R':
 033                    x++;
 34
 035                    break;
 36                case 'L':
 237                    x--;
 238                    break;
 39                case 'U':
 140                    y++;
 141                    break;
 42                case 'D':
 143                    y--;
 144                    break;
 45            }
 446        }
 47
 248        return x == 0 && y == 0;
 249    }
 50}

Methods/Properties

JudgeCircle(System.String)