c#
```\npublic class Solution {\n    public int LengthOfLongestSubstring(string s) {\n            if (s == null || s == String.Empty)\n                return 0;\n\
```\npublic class Solution {\n    public int LengthOfLongestSubstring(string s) {\n            if (s == null || s == String.Empty)\n                return 0;\n\n            HashSet<char> set = new HashSet<char>();\n            int currentMax = 0,\n                i = 0,\n                j = 0;\n\n            while (j < s.Length)\n                if (!set.Contains(s[j]))\n                {\n                    set.Add(s[j++]);\n                    currentMax = Math.Max(currentMax, j - i);\n                }\n                else\n                    set.Remove(s[i++]);\n\n            return currentMax;\n    }\n}
[]