-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo35.cs
50 lines (44 loc) · 1.01 KB
/
algo35.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
public class Kata
{
public static bool IsIsogram(string str)
{
HashSet<char> seenChars = new HashSet<char>();
foreach (char c in str.ToLower())
{
if (!char.IsLetter(c)) continue;
if (seenChars.Contains(c)) return false;
seenChars.Add(c);
}
return true;
}
}
using System;
using System.Linq;
public class Kata
{
public static bool IsIsogram(string str)
{
return str.ToLower().Distinct().Count() == str.Length;
}
}
using System;
public class Kata
{
public static bool IsIsogram(string str)
{
string str2 = str.ToLower();
for (int i = 0; i < str2.Length; i++)
{
for (int j = i + 1; j < str2.Length; j++)
{
if (str2[i] == str2[j])
{
return false;
}
}
}
return true;
}
}