Python. Cool & easy solution. O(n) time. O(1) space.
\tclass Solution:\n\t\tdef lengthOfLongestSubstring(self, s: str) -> int:\n\t\t\tcharacters = set()\n\t\t\tleft = right = ans = 0\n\t\t\tlength = len(s)\n\t\t\t
\tclass Solution:\n\t\tdef lengthOfLongestSubstring(self, s: str) -> int:\n\t\t\tcharacters = set()\n\t\t\tleft = right = ans = 0\n\t\t\tlength = len(s)\n\t\t\t\n\t\t\twhile right < length:\n\t\t\t\tif s[right] in characters:\n\t\t\t\t\tcharacters.remove(s[left])\n\t\t\t\t\tleft += 1\n\t\t\t\telse:\n\t\t\t\t\tcharacters.add(s[right])\n\t\t\t\t\tright += 1\n\t\t\t\t\tans = max(ans, right - left)\n\t\t\t\n\t\t\treturn ans
['Python', 'Python3']