Most Simple and Easy || Sliding Window || Intuitive || 2 approaches
Most Intutive:\nGiven word only contains vowels(given in question) and we just have to find out the longest substring that contains all vowels in sorted order o
**Most Intutive:**\nGiven word only contains vowels(given in question) and we just have to find out the longest substring that contains all vowels in sorted order of ascii value. i.e `\'a\'<\'e\'<\'i\'<\'o\'<\'u\' .`\nSo if a substring have 5 unique character and following ascii order we can update our answer by its length.\n\n```\nclass Solution {\n    public int longestBeautifulSubstring1(String word) {\n        int cnt=1;\n        int len=1;\n        int max_length=0;\n        \n        int n=word.length();\n        \n        for(int i=1;i<n;i++){\n            if(word.charAt(i)==word.charAt(i-1)){\n                len++;\n            }else if(word.charAt(i-1)<word.charAt(i)){\n                cnt++;\n                len++;\n            }else{\n                len=1;\n                cnt=1;\n            }\n            \n            if(cnt==5){\n                max_length=Math.max(max_length,len);\n            }\n        }\n        return max_length;\n    }```\n\t\n\t\n    //Sliding Window\n\t\n\t\n```    public int longestBeautifulSubstring(String word) {\n            int start = 0;\n            int res = 0;\n            Map<Character, Integer> charCount = new HashMap();\n            char ch = word.charAt(0);\n            charCount.put(ch, 1);\n\n            for(int end = 1; end < word.length(); end++)\n            {\n                if (word.charAt(end-1) > word.charAt(end))\n                {   \n                    charCount.clear();\n                    start = end;\n                }\n                ch = word.charAt(end);\n                charCount.put(ch, charCount.getOrDefault(ch, 0) + 1);\n\n                if(charCount.size() == 5)\n                    res=Math.max(res, end - start + 1);\n            }\n            return res;\n    }\n}\n```
['Sliding Window', 'Java']