< Summary

Information
Class: LeetCode.Algorithms.StudentAttendanceRecord1.StudentAttendanceRecord1Simulation
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\StudentAttendanceRecord1\StudentAttendanceRecord1Simulation.cs
Line coverage
92%
Covered lines: 23
Uncovered lines: 2
Coverable lines: 25
Total lines: 67
Line coverage: 92%
Branch coverage
90%
Covered branches: 9
Total branches: 10
Branch coverage: 90%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CheckRecord(...)90%101092%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\StudentAttendanceRecord1\StudentAttendanceRecord1Simulation.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2026 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.StudentAttendanceRecord1;
 13
 14/// <inheritdoc />
 15public sealed class StudentAttendanceRecord1Simulation : IStudentAttendanceRecord1
 16{
 17    /// <summary>
 18    ///     Time complexity - O(n)
 19    ///     Space complexity - O(1)
 20    /// </summary>
 21    /// <param name="s"></param>
 22    /// <returns></returns>
 23    public bool CheckRecord(string s)
 224    {
 225        var lateCount = 0;
 226        var absentCount = 0;
 27
 2628        for (var i = 0; i < s.Length; i++)
 1229        {
 1230            var c = s[i];
 31
 1232            switch (c)
 33            {
 34                case 'A':
 235                    {
 236                        absentCount++;
 37
 238                        if (absentCount > 1)
 039                        {
 040                            return false;
 41                        }
 42
 243                        lateCount = 0;
 44
 245                        break;
 46                    }
 47                case 'L':
 548                    {
 549                        lateCount++;
 50
 551                        if (lateCount > 2)
 152                        {
 153                            return false;
 54                        }
 55
 456                        break;
 57                    }
 58                default:
 559                    lateCount = 0;
 60
 561                    break;
 62            }
 1163        }
 64
 165        return true;
 266    }
 67}

Methods/Properties

CheckRecord(System.String)