✅ Python - Sliding Window approach || 99.17% faster ✅
Please upvote if you like the solution\n\n\n# Complexity\n- Time complexity:\nO(n^2)\n\n\n- Space complexity:\nO(k) -> where k is the size of the result string\
## Please upvote if you like the solution\n\n\n# Complexity\n- Time complexity:\n$$O(n^2)$$\n\n\n- Space complexity:\n$$O(k)$$ -> where k is the size of the result string\n\n\n\n# Code\n```\nclass Solution:\n    def lengthOfLongestSubstring(self, s: str) -> int:\n        # Base Case\n        if len(s) == 1: return 1\n\n\n        count, s_result = 0, \'\'\n\n        for i in s:\n            if i not in s_result:\n                s_result += i\n            else:\n                s_result = s_result[s_result.index(i)+1:] + i\n\n            if len(s_result) > count:\n                count = len(s_result)\n        \n        return count\n\n            \n\n            \n\n            \n\n        \n\n```
['Sliding Window', 'Python3']