Best C++ Solution
The basic idea is \'a\' < \'e\' < \'i\' < \'o\' < \'u\'. So this problem is to find the length of the longest non-decreasing substring that has five different c
The basic idea is `\'a\' < \'e\' < \'i\' < \'o\' < \'u\'`. So this problem is to find the length of the longest non-decreasing substring that has five different chars.\n\n```c++\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        const auto n = word.size();\n\n        int cnt = 1;\n        int len = 1;\n        int max_len = 0;\n        for (int i = 1; i != n; ++i) {\n            if (word[i - 1] == word[i]) {\n                ++len;\n            } else if (word[i - 1] < word[i]) {\n                ++len;\n                ++cnt;\n            } else {\n                cnt = 1;\n                len = 1;\n            }\n            \n            if (cnt == 5) {\n                max_len = max(max_len, len);\n            }\n        }\n        return max_len;\n    }\n};\n```
['C']