When fresher writes the code XD | O(n) beats 95%
Code\n\nclass Solution {\n    public int longestBeautifulSubstring(String s) {\n      int maxi = 0;\n      int startIdx = 0;\n      for(int i = 0 ; i < s.length
# Code\n```\nclass Solution {\n    public int longestBeautifulSubstring(String s) {\n      int maxi = 0;\n      int startIdx = 0;\n      for(int i = 0 ; i < s.length() - 1 ; i++) {\n        boolean aflg = false;\n        boolean eflg = false;\n        boolean iflg = false;\n        boolean oflg = false;\n        boolean uflg = false;\n        if(s.charAt(i) == \'a\') {\n          startIdx = i;\n          aflg = true;\n          while(i + 1 < s.length() && s.charAt(i+1) == \'a\') {\n            i++;\n          }\n          if(i + 1 < s.length() && s.charAt(i+1) != \'e\') continue;\n          while(i + 1 < s.length() && s.charAt(i+1) == \'e\') {\n            eflg = true;\n            i++;\n          }\n          if(i + 1 < s.length() && s.charAt(i+1) != \'i\') continue;\n          while(i + 1 < s.length() && s.charAt(i+1) == \'i\') {\n            iflg = true;\n            i++;\n          }\n          if(i + 1 < s.length() && s.charAt(i+1) != \'o\') continue;\n          while(i + 1 < s.length() && s.charAt(i+1) == \'o\') {\n            oflg = true;\n            i++;\n          }\n          if(i + 1 < s.length() && s.charAt(i+1) != \'u\') continue;\n          while(i + 1 < s.length() && s.charAt(i+1) == \'u\') {\n            uflg = true;\n            i++;\n          }\n          if(aflg && eflg && iflg && oflg && uflg) {\n            maxi = Math.max(maxi, i - startIdx + 1);\n          }\n        }\n      }\n      return maxi;\n    }\n}\n```
['String', 'Sliding Window', 'Java']