Java O(n) solution, simple to understand
public int longestBeautifulSubstring(String word) {\n        \n        int max = 0;\n        int count = 1, i = 0, j = 1;\n        \n        while(j < word.leng
public int longestBeautifulSubstring(String word) {\n        \n        int max = 0;\n        int count = 1, i = 0, j = 1;\n        \n        while(j < word.length()){\n            \n            if(word.charAt(j) < word.charAt(j-1)){\n                i = j; \n                count = 1;\n            }\n            \n            else if(word.charAt(j) != word.charAt(j-1))\n                count++;\n    \n            if(count==5)\n                max = Math.max(max, j-i+1);  \n            \n            j++;\n        }\n        return max;\n    }\n\t\n\tPlease upvote if you find it simple to understand
['Sliding Window', 'Java']