public class Solution
{
public int LengthOfLongestSubstring(string s)
{
var set = new HashSet<char>();
int left = 0, maxLength = 0;
for (int right = 0; right < s.Length; right++)
{
while (set.Contains(s[right]))
{
set.Remove(s[right]);
left++;
}
set.Add(s[right]);
maxLength = Math.Max(maxLength, right - left + 1);
}
return maxLength;
}
}
Span<int> number = stackalloc int[5];
for(int i = 0; i < 5; i++)
number[i] = i;
Console.WriteLine(string.Join("," , number.ToArray()));