JAVA || Sliding Window || if -else || easy solution by 2 methods
\n  public int longestBeautifulSubstring(String word) {\n       \n       int count =1,vowels=1,ans=0;\n        \n        for(int i=1;i<word.length();i++){\n    
```\n  public int longestBeautifulSubstring(String word) {\n       \n       int count =1,vowels=1,ans=0;\n        \n        for(int i=1;i<word.length();i++){\n            char cur=word.charAt(i);\n            char pre=word.charAt(i-1);\n            \n           if(pre>cur){\n               count=1;\n               vowels=1;\n           }else if(pre < cur){\n               count++;\n               vowels++;\n           }else{\n               count++;\n           } \n            \n          if(vowels==5){\n              ans=Math.max(ans,count);\n          } \n            \n            \n        }\n        return ans;\n        \n        \n    }\n```\n **Sliding window:-**\n```\n   int i=0,j=1;\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          \n          if(count==5){\n              ans=Math.max(ans,j-i+1);\n          }\n          \n          j++;\n      } \n        \n        \n     return ans;   \n        \n```\nplease upvote it  if you find it simple to understand
['Sliding Window', 'Java']