Sliding Window Template | C++
\n\n# Code\n\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string nums) {\n        int n=nums.size();\n        if (n<5) return 0;\n        int c
\n\n# Code\n```\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string nums) {\n        int n=nums.size();\n        if (n<5) return 0;\n        int count=1,maxi=0;\n        set<char> st;\n        st.insert(nums[0]);\n        for (int i=1;i<n;i++)\n        {\n            if (nums[i]>=nums[i-1])\n                count++;\n            else\n            {\n                st.clear();\n                count=1;\n            }\n            st.insert(nums[i]);\n            if (st.size()==5)\n                  maxi=max(maxi,count);\n        }\n        return maxi;\n    }\n};\n```
['C++']