A Python solution - 85ms - O(n)
class Solution:\n        # @return an integer\n        def lengthOfLongestSubstring(self, s):\n            start = maxLength = 0\n            usedChar = {}\n   
    class Solution:\n        # @return an integer\n        def lengthOfLongestSubstring(self, s):\n            start = maxLength = 0\n            usedChar = {}\n            \n            for i in range(len(s)):\n                if s[i] in usedChar and start <= usedChar[s[i]]:\n                    start = usedChar[s[i]] + 1\n                else:\n                    maxLength = max(maxLength, i - start + 1)\n    \n                usedChar[s[i]] = i\n    \n            return maxLength
['Python']