< Summary

Information
Class: LeetCode.Algorithms.CheckIfTheSentenceIsPangram.CheckIfTheSentenceIsPangramHashSet
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CheckIfTheSentenceIsPangram\CheckIfTheSentenceIsPangramHashSet.cs
Line coverage
100%
Covered lines: 36
Uncovered lines: 0
Coverable lines: 36
Total lines: 64
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
CheckIfPangram(...)100%22100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\CheckIfTheSentenceIsPangram\CheckIfTheSentenceIsPangramHashSet.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.CheckIfTheSentenceIsPangram;
 13
 14/// <inheritdoc />
 15public class CheckIfTheSentenceIsPangramHashSet : ICheckIfTheSentenceIsPangram
 16{
 417    private readonly HashSet<char> _alphabetHashSet =
 418    [
 419        'a',
 420        'b',
 421        'c',
 422        'd',
 423        'e',
 424        'f',
 425        'g',
 426        'h',
 427        'i',
 428        'j',
 429        'k',
 430        'l',
 431        'm',
 432        'n',
 433        'o',
 434        'p',
 435        'q',
 436        'r',
 437        's',
 438        't',
 439        'u',
 440        'v',
 441        'w',
 442        'x',
 443        'y',
 444        'z'
 445    ];
 46
 47    /// <summary>
 48    ///     Time complexity - O(n)
 49    ///     Space complexity - O(n)
 50    /// </summary>
 51    /// <param name="sentence"></param>
 52    /// <returns></returns>
 53    public bool CheckIfPangram(string sentence)
 454    {
 455        if (sentence.Length < 26)
 156        {
 157            return false;
 58        }
 59
 360        var sentenceHashSet = new HashSet<char>(sentence);
 61
 362        return _alphabetHashSet.All(sentenceHashSet.Contains);
 463    }
 64}