C++ Solution using Set
```\n    int lengthOfLongestSubstring(string s) {\n        int n=s.length();\n        if(n==0)\n            return 0;\n        set st;\n        int maxsize=0;\n
```\n    int lengthOfLongestSubstring(string s) {\n        int n=s.length();\n        if(n==0)\n            return 0;\n        set<char> st;\n        int maxsize=0;\n        int i=0,j=0;\n        while(j<n)\n        {\n            if(st.count(s[j])==0)\n            {\n                st.insert(s[j]);\n                maxsize=max(maxsize,(int)st.size());\n                j++;\n            }\n            else\n            {\n                st.erase(s[i]);\n                i++;\n            }\n        }\n        return maxsize;\n    }\n\t
['C', 'Ordered Set', 'C++']