[Python] One pass - Clean & Concise
Python\npython\nclass Solution:\n    def lengthOfLongestSubstring(self, s: str) -> int:\n        ans = 0\n        l = 0\n        lastIndex = [-1] * 128\n       
**Python**\n```python\nclass Solution:\n    def lengthOfLongestSubstring(self, s: str) -> int:\n        ans = 0\n        l = 0\n        lastIndex = [-1] * 128\n        for r, c in enumerate(s):\n            l = max(l, lastIndex[ord(c)] + 1)\n            lastIndex[ord(c)] = r\n            ans = max(ans, r - l + 1)\n        return ans\n```\n**Complexity**\n- Time: `O(N)`, where `N <= 5 * 10^4` is length of string `s`.\n- Space: `O(128)`
[]