[Python] - Bruteforce O(n) - Simple easy to follow solution
Intuition --> \nKeep track of the previous character and it has to be in sequence so the else condition follows accordingly. \n\nTime Complexity:- O(n)\n\n\ncla
Intuition --> \nKeep track of the previous character and it has to be in sequence so the else condition follows accordingly. \n\nTime Complexity:- O(n)\n\n```\nclass Solution:\n    def longestBeautifulSubstring(self, word: str) -> int:\n        s=0\n        prev=\'a\'\n        l=[]\n        for char in word:\n            if char == \'a\' and prev == \'a\':\n                prev=char\n                s+=1\n            elif char == \'e\' and (prev == \'a\' or prev==\'e\'):\n                prev=char\n                s+=1\n            elif char == \'i\' and (prev ==\'e\' or prev==\'i\'):\n                prev=char\n                s+=1\n            elif char == \'o\' and (prev == \'i\' or prev==\'o\'):\n                prev=char\n                s+=1\n            elif char==\'u\' and (prev ==\'o\' or prev==\'u\'):\n                prev=char\n                s+=1\n                if s>=5:\n                    l.append(s)\n            else:\n                if char !=\'a\':\n                    s=0\n                    prev=\'a\'\n                else:\n                    s=1\n                    prev=char\n            \n        if not l:\n            return 0\n        else:\n            return max(l)\n```
['Python', 'Python3']