C++ || Sliding Window || Keeping it S!mple
\nclass Solution {\npublic:\n    int lengthOfLongestSubstring(string s) {\n        unordered_set<char>sub;//set to store occoured character\n        int left=0,
```\nclass Solution {\npublic:\n    int lengthOfLongestSubstring(string s) {\n        unordered_set<char>sub;//set to store occoured character\n        int left=0,right=0; //two pointers to navigate\n        int max_size=0;\n        while(left<s.size() && right<s.size())\n        {\n            //if the char is not in the subset\n            //put it in the set\n            //find the max size\n            if(sub.find(s[right])==sub.end())\n            {\n                sub.insert(s[right]);\n                int n=sub.size();\n                max_size=max(max_size,n);\n                right++;\n            }\n            //if already there \n            //shrink the window from left \n            //until the repeated char is not omitted from left\n            else\n            {\n                sub.erase(s[left]);\n                left++;\n            }\n        }\n        return max_size;\n    }\n};\n```\nIf you find any issue in understanding the solutions then comment below, will try to help you.\nIf you found my solution useful.\nSo please do upvote and encourage me to document all leetcode problems\uD83D\uDE03\nHappy Coding :)
['C', 'Ordered Set']