C++ || Two Pointers || Beats 100% Time and Space
class Solution {\npublic:\n\n    int longestBeautifulSubstring(string word) {\n        int i=0;\n        int j=1;\n        int count=1;\n        int ans=0;\n   
class Solution {\npublic:\n\n    int longestBeautifulSubstring(string word) {\n        int i=0;\n        int j=1;\n        int count=1;\n        int ans=0;\n        char ch=word[0];\n        while(j<word.length()){\n            if(ch==word[j]){\n                j++;\n                continue;\n            }\n            if(ch<word[j]){\n                ch=word[j];\n                j++;\n                count++;\n            }else{\n                if(count==5){\n                    ans=max(ans,j-i);\n                }\n                i=j;\n                j++;\n                ch=word[i];\n                count=1;\n            }\n        }\n        if(count==5){\n            ans=max(ans,j-i);\n        }\n        return ans;\n    }\n};
[]