static int large_substring(string str)
if (string.IsNullOrEmpty(str))
int CurrentCountChars = 1;
int[] visited = new int[Chars];
for (int i = 0; i < Chars; i++)
for (int i = 1; i < str.Length; i++)
PreviousIndex = visited[str[i]];
if (PreviousIndex == -1 || i - CurrentCountChars > PreviousIndex)
if (CurrentCountChars > MaxCountChars)
MaxCountChars = CurrentCountChars;
CurrentCountChars = i - PreviousIndex;
if (CurrentCountChars > MaxCountChars)
MaxCountChars = CurrentCountChars;
public static void Main()
if (large_substring("afsdffsd") == 4)
Console.WriteLine("Тест 1 пройден");
if (large_substring("") == 0)
Console.WriteLine("Тест 2 пройден");
if (large_substring("ffffffffffff") == 1)
Console.WriteLine("Тест 3 пройден");
if (large_substring("abcdefghijklmnopqrstuvwxyz") == 26)
Console.WriteLine("Тест 4 пройден");
if (large_substring("afsdffsdQPODDDD") == 7)
Console.WriteLine("Тест 5 пройден");