SLIDING WINDOW || O(n) || Faster than 90% and Memory usage less than 100%
\nclass Solution {\npublic:\n    int lengthOfLongestSubstring(string s) {\n        \n        //SLIDING WINDOW  - TIME COMPLEXITY O(2n)\n        //              
```\nclass Solution {\npublic:\n    int lengthOfLongestSubstring(string s) {\n        \n        //SLIDING WINDOW  - TIME COMPLEXITY O(2n)\n        //                  SPACE COMPLEXITY O(m)   //size of array\n        \n        int store[256]={0}; //array to store the occurences of all the characters\n        int l=0;    //left pointer\n        int r=0;    //right pointer\n        int ans=0;  //initializing the required length as 0\n        \n        while(r<s.length())     //iterate over the string till the right pointer reaches the end of the string \n        {\n            store[s[r]]++;      //increment the count of the character present in the right pointer \n            \n            while(store[s[r]]>1)    //if the occurence become more than 1 means the char is repeated\n            { \n                store[s[l]]--;   //reduce the occurence of temp as it might be present ahead also in the string\n                l++;         //contraction of the present window till the occurence of the \'t\' char becomes 1\n            }\n            \n            ans = max(ans,r-l+1);    //As the index starts from 0 , ans will be (right pointer-left pointer + 1)\n            r++;        // now will increment the right pointer \n        }\n        return ans;\n    }\n};\n```\n**If you like it, Do upvote \nHappy Coding;**\n\n
['C', 'Sliding Window', 'C++']