✅✅Easiest Python Solution | O(n) | Simple linear✅✅no stack/greedy/sliding window/two pointers
Approach\nc is the current counter\nm is the max\np is the pointer on the array a, remembering the current char\n\nIncrement c if the current char is the pointe
# Approach\nc is the current counter\nm is the max\np is the pointer on the array a, remembering the current char\n\nIncrement c if the current char is the pointer char.\nIncrement c and p if the current char is the next pointer char.\nOtherwise make c the new m if the pointer is at the end of the array c is bigger than m. Set p to -1 and keep it at that while we do not start a new chain with the first letter "a".\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n\n# Code\n```\nclass Solution:\n    def longestBeautifulSubstring(self, word: str) -> int:\n        a = ["a", "e", "i", "o", "u"]\n        c, m, p, = 0, 0, 0\n\n        for x in word:\n            if p >= 0 and x == a[p]:  c += 1\n            elif -1 < p < 4 and c > 0 and x == a[p+1]:\n                c += 1\n                p += 1\n            else:     \n                if p == 4 and c > m: m = c\n                c = 0\n                if x == "a": \n                    c += 1\n                    p = 0\n                else: p = -1\n        return m if p != 4 else max(c,m)\n```
['Python3']