< Summary

Information
Class: LeetCode.Algorithms.OneBitAndTwoBitCharacters.OneBitAndTwoBitCharactersIterative
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\OneBitAndTwoBitCharacters\OneBitAndTwoBitCharactersIterative.cs
Line coverage
78%
Covered lines: 11
Uncovered lines: 3
Coverable lines: 14
Total lines: 41
Line coverage: 78.5%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
IsOneBitCharacter(...)75%4478.57%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\OneBitAndTwoBitCharacters\OneBitAndTwoBitCharactersIterative.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.OneBitAndTwoBitCharacters;
 13
 14/// <inheritdoc />
 15public sealed class OneBitAndTwoBitCharactersIterative : IOneBitAndTwoBitCharacters
 16{
 17    /// <summary>
 18    ///     Time complexity - O(n)
 19    ///     Space complexity - O(1)
 20    /// </summary>
 21    /// <param name="bits"></param>
 22    /// <returns></returns>
 23    public bool IsOneBitCharacter(int[] bits)
 224    {
 225        var i = 0;
 26
 527        while (i < bits.Length - 1)
 328        {
 329            if (bits[i] == 0)
 030            {
 031                i++;
 032            }
 33            else
 334            {
 335                i += 2;
 336            }
 337        }
 38
 239        return i == bits.Length - 1;
 240    }
 41}