C++ || Stack || Esay to Understand
class Solution {\npublic:\n  \n  \n  int longestBeautifulSubstring(string word) {\n        \n        int n = word.size();\n        stack st;\n        unordered_
class Solution {\npublic:\n  \n  \n  int longestBeautifulSubstring(string word) {\n        \n        int n = word.size();\n        stack<char> st;\n        unordered_map<char,int> mp;\n        int res = 0;\n        \n        \n        for(int i=0; i<n; i++){\n            \n            char ch = word[i];\n            \n            if(!st.empty() and st.top() > ch){\n                \n                mp.clear();\n                while(!st.empty()) st.pop();\n                \n            }\n            \n            mp[ch]++;\n            st.push(ch);\n            \n            if(mp.size() >= 5){\n                \n                if(st.size() > res){\n                    res = st.size();\n                }\n            }\n            \n        }\n        \n        \n        return res;\n        \n    }\n};
['Stack', 'C', 'C++']