< Summary

Information
Class: LeetCode.Algorithms.MaximumSubstringsWithDistinctStart.MaximumSubstringsWithDistinctStartBitMask
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\MaximumSubstringsWithDistinctStart\MaximumSubstringsWithDistinctStartBitMask.cs
Line coverage
88%
Covered lines: 16
Uncovered lines: 2
Coverable lines: 18
Total lines: 50
Line coverage: 88.8%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
MaxDistinct(...)83.33%6688.88%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\MaximumSubstringsWithDistinctStart\MaximumSubstringsWithDistinctStartBitMask.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.MaximumSubstringsWithDistinctStart;
 13
 14/// <inheritdoc />
 15public sealed class MaximumSubstringsWithDistinctStartBitMask : MaximumSubstringsWithDistinctStartBase
 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 override int MaxDistinct(string s)
 324    {
 325        var mask = 0;
 326        var result = 0;
 27
 3028        for (var i = 0; i < s.Length; i++)
 1229        {
 1230            var index = GetIndex(s[i]);
 1231            var bit = 1 << index;
 32
 1233            if ((mask & bit) != 0)
 534            {
 535                continue;
 36            }
 37
 738            mask |= bit;
 39
 740            result++;
 41
 742            if (result == 26)
 043            {
 044                break;
 45            }
 746        }
 47
 348        return result;
 349    }
 50}

Methods/Properties

MaxDistinct(System.String)