Skip to content

Commit

Permalink
feat(DetectPangram): add solution.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusViniciusSS committed Mar 6, 2023
1 parent d43c5b6 commit 6fff585
Showing 1 changed file with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace CodeWarsChallenges.Strings._6kyu.Detect_Pangram;

public static class DetectPangram
{
private static readonly HashSet<int> ASCIIAlphabet = new()
{
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90
};


public static bool IsPangram(string str)
{
var countAlphabet = ASCIIAlphabet.Count;
var hashSet = new HashSet<int>();
var stringUpper = str.ToUpper();
var count = 0;

for (var i = 0; i < stringUpper.Length; i++)
{
if (count == countAlphabet)
return true;

if (!ASCIIAlphabet.Contains((int)stringUpper[i]))
continue;

if (hashSet.Contains((int) stringUpper[i]))
continue;

hashSet.Add(stringUpper[i]);
count++;
}

return count == countAlphabet;
}
}

0 comments on commit 6fff585

Please sign in to comment.