Simple Python3 Solution using Sliding window || Beats 99% || 💻🧑‍💻🤖
\n\n# Code\n\nclass Solution:\n    def lengthOfLongestSubstring(self, s: str) -> int:\n        l=len(s)\n        if l==0:\n            return 0\n        dicts={
\n\n# Code\n```\nclass Solution:\n    def lengthOfLongestSubstring(self, s: str) -> int:\n        l=len(s)\n        if l==0:\n            return 0\n        dicts={}\n        max_len=0\n        start=0\n        for i in range(l):\n            if s[i] in dicts and start<=dicts[s[i]]:\n                start = dicts[s[i]]+1\n            else:\n                max_len=max(max_len,i-start+1)\n            dicts[s[i]]=i\n        return max_len\n        \n```\n![7abc56.jpg](https://assets.leetcode.com/users/images/b0e5a9a2-a2a2-452d-9a1b-33d9fbab7296_1694192336.7716062.jpeg)\n
['Python3']