//*10.Check if a String Has All Unique Characters * > "abcdef" → true, "apple" → false.
string s1 = "apple";
var d1 = s1
.GroupBy(x => x)
.ToDictionary(x => x.Key, y => y.Count());
foreach (var item in d1)
{
if(item.Value > 1)
{
Console.WriteLine("Repeating character - " + item.Key);
return;
}
}
string s1 = "apple";
var d1 = s1
.GroupBy(x => x)
.ToDictionary(x => x.Key, y => y.Count());
foreach (var item in d1)
{
if(item.Value > 1)
{
Console.WriteLine("Repeating character - " + item.Key);
return;
}
}
No comments:
Post a Comment