In this problem, a String S is composed of lowercase alphabets and wildcard characters i.e. '?'. Here, '?' can be replaced by any of the lowercase alphabets. Now you have to classify the given String on the basis of following rules:
If there are more than 3 consonants together or more than 5 vowels together, the String is considered to be "BAD". A String is considered "GOOD" only if it is not “BAD”.
NOTE: String is considered as "BAD" if the above condition is satisfied even once. Else it is "GOOD" and the task is to make the string "BAD".
 
Example 1:
Input:
S = aeioup??
Output:
1
Explanation: The String doesn't contain more
than 3 consonants or more than 5 vowels together.
So, it's a GOOD string.
Example 2:
Input:
S = bcdaeiou??
Output:
0
Explanation: The String contains the
Substring "aeiou??" which counts as 7
vowels together. So, it's a BAD string.
Your Task:
You don't need to read input or print anything. Your task is to complete the function isGoodorBad() which takes the String S as input and returns 0 or 1.
 
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= |S| <= 100000

Source: geeksforgeeks | Difficulty: EASY
Tags: String algorithms

Data structures

Greedy algorithms

Starter code: #User function Template for python3



class Solution:

    def isGoodorBad(self, S):

        # code here 

Solutions:
class Solution:

	def isGoodorBad(self, S):
		pattern = '[aeiou]+[?]*|[^aeiou]+[?]*'
		import re
		x = re.findall(pattern, S)
		c = 0
		for i in x:
			if i[0] in 'aeiou' and len(i) > 5 or (i[0] not in 'aeiou' and len(i) > 3):
				c += 1
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		x = 0
		y = 0
		xm = 0
		ym = 0
		c = 0
		st = 'aeiou'
		for i in range(len(S)):
			if S[i].isalpha() and S[i] not in st:
				y = 0
				x += 1
			elif S[i] in st:
				x = 0
				y += 1
			else:
				c += 1
				if S[i - c] in st:
					y += 1
				else:
					x += 1
			if x > xm:
				xm = x
			if y > ym:
				ym = y
		if xm > 3 or ym > 5:
			return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, S):
		vowel = 'aeiou'
		v1 = 0
		c1 = 0
		for i in S:
			if i in vowel:
				v1 += 1
				c1 = 0
			elif i == '?':
				v1 += 1
				c1 += 1
			else:
				c1 += 1
				v1 = 0
			if v1 > 5 or c1 > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = 'aeiou'
		vowel_count = 0
		consonant_count = 0
		for char in S:
			if char == '?':
				vowel_count += 1
				consonant_count += 1
			elif char in vowels:
				vowel_count += 1
				consonant_count = 0
			else:
				consonant_count += 1
				vowel_count = 0
			if consonant_count == 4 or vowel_count == 6:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = ['a', 'e', 'i', 'o', 'u']
		count = 0
		for i in range(len(S)):
			if S[i] in vowels or S[i] == '?':
				count += 1
				if count > 5:
					return '0'
			else:
				count = 0
		count1 = 0
		for i in range(len(S)):
			if S[i] not in vowels or S[i] == '?':
				count1 += 1
				if count1 > 3:
					return '0'
			else:
				count1 = 0
		return '1'


class Solution:

	def isGoodorBad(self, s):
		cc = 0
		vc = 0
		qc = 0
		for i in range(len(s)):
			if s[i] == '?':
				if cc > 0:
					cc += 1
				elif vc > 0:
					vc += 1
				else:
					qc += 1
			elif s[i] == 'a' or s[i] == 'i' or s[i] == 'e' or (s[i] == 'o') or (s[i] == 'u'):
				vc += 1
				cc = 0
				if qc > 0:
					vc += qc
					qc = 0
			elif s[i] != 'a' and s[i] != 'i' and (s[i] != 'e') and (s[i] != 'o') and (s[i] != 'u'):
				cc += 1
				vc = 0
				if qc > 0:
					cc += qc
					qc = 0
			if vc > 5 or cc > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		d = {'v': 0, 'u': 0}
		l = ['a', 'e', 'i', 'o', 'u']
		for i in S:
			if i in l:
				d['u'] = 0
				d['v'] += 1
				if d['v'] > 5:
					return 0
			elif i == '?':
				d['v'] += 1
				d['u'] += 1
				if d['v'] > 5:
					return 0
				if d['u'] > 3:
					return 0
			else:
				d['v'] = 0
				d['u'] += 1
				if d['u'] > 3:
					return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = 'aeiou'
		maxVowelLen = 0
		maxConsonantLen = 0
		vowels = 'aeiou'
		i = 0
		while i < len(S):
			if S[i] in vowels:
				j = i + 1
				while j < len(S) and (S[j] in vowels or S[j] == '?'):
					j += 1
				maxVowelLen = max(maxVowelLen, j - i)
				if maxVowelLen > 5:
					return 0
			else:
				j = i + 1
				while j < len(S) and S[j] not in vowels:
					j += 1
				maxConsonantLen = max(maxConsonantLen, j - i)
				if maxConsonantLen > 3:
					return 0
			i = j
		return 1


class Solution:

	def isGoodorBad(self, S):
		countv = 0
		countc = 0
		for i in S:
			if i == '?' and (countv == 5 or countc == 3):
				return 0
			if i == 'a' or i == 'e' or i == 'i' or (i == 'o') or (i == 'u'):
				countv += 1
				countc = 0
			else:
				countv = 0
				countc += 1
			if countv > 5 or countc > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = 'aeiou'
		vowels_count = 0
		consonant_count = 0
		for i in S:
			if i == '?':
				vowels_count += 1
				consonant_count += 1
			elif i in vowels:
				vowels_count += 1
				consonant_count = 0
			else:
				consonant_count += 1
				vowels_count = 0
			if consonant_count == 4 or vowels_count == 6:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		c = 0
		c1 = 0
		str = 'aeiou'
		for i in S:
			if i in str or i == '?':
				c += 1
				if c > 5:
					return 0
			else:
				c = 0
			if i not in str or i == '?':
				c1 += 1
				if c1 > 3:
					return 0
			else:
				c1 = 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		c = 0
		d = 0
		for let in S:
			if let == '?' and c > 4:
				return 0
			if let in 'aeiou':
				c += 1
				d = 0
				if c > 5:
					return 0
			else:
				c = 0
				d += 1
				if d > 3:
					return 0
		return 1


class Solution:

	def isGoodorBad(self, s):
		count = 0
		count1 = 0
		v = 'aeiou'
		for i in s:
			if i in v or i == '?':
				count += 1
				if count > 5:
					return 0
			else:
				count = 0
			if i not in v or i == '?':
				count1 += 1
				if count1 > 3:
					return 0
			else:
				count1 = 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = {'a', 'e', 'i', 'o', 'u'}
		cons = 0
		max_cons = 0
		for i in range(0, len(S)):
			if S[i] in vowels:
				cons = 0
			else:
				cons = cons + 1
			max_cons = max(max_cons, cons)
		vow = 0
		max_vow = 0
		for i in range(0, len(S)):
			if S[i] not in vowels and S[i] != '?':
				vow = 0
			else:
				vow = vow + 1
			max_vow = max(max_vow, vow)
		if max_cons > 3 or max_vow > 5:
			return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		a = S
		vowel = ['a', 'e', 'i', 'o', 'u']
		vo = 0
		cons = 0
		flag = 0
		fin = 1
		for i in range(len(a)):
			if a[i] in vowel:
				vo += 1
				cons = 0
				if vo > 5:
					fin = 0
					break
			elif a[i] == '?':
				vo += 1
				cons += 1
				if vo > 5:
					fin = 0
					break
				if cons > 3:
					fin = 0
					break
			else:
				cons += 1
				vo = 0
				if cons > 3:
					fin = 0
					break
		return fin


class Solution:

	def isGoodorBad(self, S):
		Vowel = 'aeiou'
		symbol = '?!'
		v_count = 0
		c_count = 0
		for i in S:
			if i in Vowel:
				v_count += 1
				c_count = 0
			elif i in symbol:
				v_count += 1
				c_count += 1
			else:
				c_count += 1
				v_count = 0
			if v_count > 5 or c_count > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowel = 'aeiou'
		vow_count = 0
		cons_count = 0
		for char in S:
			if char == '?':
				vow_count += 1
				cons_count += 1
			elif char in vowel:
				vow_count += 1
				cons_count = 0
			else:
				vow_count = 0
				cons_count += 1
			if vow_count > 5 or cons_count > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels_count = 0
		consonant_count = 0
		for i in range(len(S)):
			if consonant_count > 3 or vowels_count > 5:
				return 0
			elif S[i] == '?':
				vowels_count += 1
				consonant_count += 1
			elif S[i] == 'a' or S[i] == 'e' or S[i] == 'i' or (S[i] == 'o') or (S[i] == 'u'):
				vowels_count += 1
				consonant_count = 0
			else:
				consonant_count += 1
				vowels_count = 0
		if vowels_count > 5 or consonant_count > 3:
			return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = ['a', 'e', 'i', 'o', 'u']
		vowel_count = 0
		consonant_count = 0
		for c in S:
			if c == '?':
				vowel_count += 1
				consonant_count += 1
			elif c in vowels:
				vowel_count += 1
				consonant_count = 0
			else:
				consonant_count += 1
				vowel_count = 0
			if vowel_count > 5 or consonant_count > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = 'aeiou'
		v_count = 0
		consonants = 'bcdfghjklmnpqrstvwxyz'
		c_count = 0
		for i in S:
			if i in vowels:
				v_count = v_count + 1
				c_count = 0
			elif i in consonants:
				c_count = c_count + 1
				v_count = 0
			elif i == '?':
				c_count = c_count + 1
				v_count = v_count + 1
			if c_count > 3 or v_count > 5:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vow = 0
		con = 0
		flag = 0
		for i in range(len(S)):
			if S[i] == 'a' or S[i] == 'e' or S[i] == 'i' or (S[i] == 'o') or (S[i] == 'u'):
				vow += 1
				con = 0
			elif S[i] != 'a' and S[i] != 'e' and (S[i] != 'i') and (S[i] != 'o') and (S[i] != 'u') and (S[i] != '?'):
				vow = 0
				con += 1
			if S[i] == '?':
				con += 1
				vow += 1
			if vow > 5 or con > 3:
				flag = 1
				break
		if flag == 1:
			return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, S):
		vc = 0
		cc = 0
		vowel = 'aeiou'
		for i in range(len(S)):
			if S[i] == '?':
				vc += 1
				if vc > 5:
					return 0
				cc += 1
			elif S[i] in vowel:
				vc += 1
				cc = 0
			elif S[i] not in vowel:
				cc += 1
				if cc > 3:
					return 0
				vc = 0
		if vc > 5 or cc > 3:
			return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, S):
		conson = 0
		vowel = 0
		vo = 'aeiou'
		for i in range(len(S)):
			if S[i] == '?':
				vowel += 1
				conson += 1
			elif S[i] in vo:
				conson = 0
				vowel += 1
			else:
				conson += 1
				vowel = 0
			if vowel > 5 or conson > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		v = 0
		c = 0
		for i in S:
			if i == '?':
				c += 1
				v += 1
			elif i in 'AEIOUaeiou':
				v += 1
				c = 0
			else:
				c += 1
				v = 0
			if v == 6 or c == 4:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, s):
		vowels = 0
		consonants = 0
		l = ['a', 'e', 'i', 'o', 'u']
		for ch in s:
			if ch == '?':
				vowels += 1
				consonants += 1
			elif ch in l:
				vowels += 1
				consonants = 0
			else:
				vowels = 0
				consonants += 1
			if consonants > 3 or vowels > 5:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, s):
		con = 0
		vow = 0
		for i in s:
			if i == 'a' or i == 'e' or i == 'i' or (i == 'o') or (i == 'u'):
				vow = vow + 1
				con = 0
			elif i == '?':
				vow = vow + 1
				con = con + 1
			else:
				vow = 0
				con = con + 1
			if con == 4 or vow == 6:
				return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, s):
		consonantCount = 0
		vowelCount = 0
		vowels = 'aeiou'
		for i in s:
			if i == '?':
				vowelCount += 1
				consonantCount += 1
			elif i in vowels:
				vowelCount += 1
				consonantCount = 0
			else:
				consonantCount += 1
				vowelCount = 0
			if consonantCount == 4 or vowelCount == 6:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		con = 0
		vo = 0
		for i in S:
			if i == 'a' or i == 'e' or i == 'i' or (i == 'o') or (i == 'u'):
				vo = vo + 1
				con = 0
			elif i == '?':
				vo = vo + 1
				con = con + 1
			else:
				vo = 0
				con = con + 1
			if con == 4 or vo == 6:
				return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = 'aeiou'
		count_vow = 0
		count_con = 0
		for char in S:
			if char in vowels:
				count_vow += 1
				count_con = 0
			elif char == '?':
				count_vow += 1
				count_con += 1
			else:
				count_con += 1
				count_vow = 0
			if count_con > 3 or count_vow > 5:
				return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = ['a', 'e', 'i', 'o', 'u']
		wildcard = ['?']
		count_vowels = 0
		count_consonants = 0
		flag = 0
		for (count, i) in enumerate(S):
			if i in vowels:
				count_vowels += 1
				count_consonants = 0
			elif i not in vowels and i not in wildcard:
				count_vowels = 0
				count_consonants += 1
			elif i == '?':
				if S[count - 1] in vowels:
					flag = 1
				elif S[count - 1] not in vowels and S[count - 1] != '?':
					flag = 0
				if flag == 1:
					count_vowels += 1
				if flag == 0:
					count_consonants += 1
			if count_vowels == 6 or count_consonants == 4:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowel = 0
		cons = 0
		for i in S:
			if i == '?':
				vowel += 1
				cons += 1
				if cons > 3 or vowel > 5:
					return 0
			elif i in ['a', 'e', 'i', 'o', 'u']:
				vowel += 1
				if cons > 3 or vowel > 5:
					return 0
				cons = 0
			else:
				cons += 1
				if cons > 3 or vowel > 5:
					return 0
				vowel = 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vovels = 'aeiou'
		vcount = 0
		ccount = 0
		for i in range(len(S)):
			if S[i] == '?':
				S = S[0:i] + S[i - 1] + S[i + 1:]
			if S[i] in vovels:
				vcount += 1
				ccount = 0
			else:
				ccount += 1
				vcount = 0
			if vcount > 5 or ccount > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, s):
		x1 = 'aeiou?'
		x2 = 'bcdfghjklmnpqrstvwxyz?'
		f = 1
		for i in range(len(s) - 1):
			for j in range(i, len(s) - 1):
				if s[j] in x1 and s[j + 1] in x1:
					f += 1
				else:
					break
			if f > 5:
				return 0
			else:
				f = 1
			m = 1
		for i in range(len(s) - 1):
			for j in range(i, len(s) - 1):
				if s[j] in x2 and s[j + 1] in x2:
					m += 1
				else:
					break
			if m > 3:
				return 0
			else:
				m = 1
		return 1


class Solution:

	def isGoodorBad(self, S):
		v = 'aeiou'
		vowels = 0
		consonants = 0
		for i in S:
			if i == '?':
				vowels += 1
				consonants += 1
			elif i in v:
				vowels += 1
				consonants = 0
			else:
				vowels = 0
				consonants += 1
			if consonants > 3 or vowels > 5:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vow = 'aeiou'
		vowcount = 0
		conscount = 0
		for i in S:
			if i == '?':
				vowcount += 1
				conscount += 1
			elif i in vow:
				vowcount += 1
				conscount = 0
			else:
				conscount += 1
				vowcount = 0
			if vowcount == 6 or conscount == 4:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		(count1, count2) = (0, 0)
		l = 0
		for i in S:
			if i in ('a', 'e', 'i', 'o', 'u'):
				count1 += 1
				count2 = 0
			elif i == '?':
				count2 += 1
				count1 += 1
			else:
				count2 += 1
				count1 = 0
			if count1 > 5 or count2 > 3:
				return 0
			l += 1
		return 1


class Solution:

	def isGoodorBad(self, S):
		ccount = 0
		vcount = 0
		for i in S:
			if i == 'a' or i == 'e' or i == 'i' or (i == 'o') or (i == 'u'):
				vcount += 1
				ccount = 0
			elif i == '?':
				vcount += 1
				ccount += 1
			else:
				ccount += 1
				vcount = 0
			if vcount > 5 or ccount > 3:
				return 0
				break
		return 1


class Solution:

	def isGoodorBad(self, S):
		vovel_count = 0
		counter = 0
		for i in S:
			if i == '?':
				vovel_count += 1
				counter += 1
			elif i in 'aeiou':
				vovel_count += 1
				counter = 0
			else:
				counter += 1
				vovel_count = 0
			if vovel_count == 6 or counter == 4:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowel = 'aeiou'
		count1 = 0
		count2 = 0
		for i in range(len(S)):
			if S[i] == '?':
				count1 += 1
				count2 += 1
			elif S[i] in vowel:
				count2 = 0
				count1 += 1
			else:
				count1 = 0
				count2 += 1
			if count1 == 6 or count2 == 4:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		ls1 = ['a', 'e', 'i', 'o', 'u']
		ls2 = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']
		ls = list(S)
		count1 = 0
		count2 = 0
		for e in ls:
			if e in ls1:
				count1 += 1
				count2 = 0
			if e in ls2:
				count2 += 1
				count1 = 0
			if e == '?':
				count1 += 1
				count2 += 1
			if count1 > 5 or count2 > 3:
				return 0
		if count1 > 5 or count2 > 3:
			return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = 'aeiou'
		vowels_continous = True
		consonant_continous = True
		count_vowels = 0
		count_consonant = 0
		BAD = 0
		GOOD = 1
		for i in range(len(S)):
			if S[i] in vowels or ((S[i] is '?' and S[i - 1] in vowels) and vowels_continous is True):
				count_vowels += 1
				consonant_continous = False
				count_consonant = 0
				vowels_continous = True
				if count_vowels > 5 and vowels_continous is True:
					return BAD
			if S[i] not in vowels or ((S[i] is '?' and S[i - 1] not in vowels) and consonant_continous is True):
				count_consonant += 1
				vowels_continous = False
				consonant_continous = True
				count_vowels = 0
				if count_consonant > 3 and consonant_continous is True:
					return BAD
		return GOOD


class Solution:

	def isGoodorBad(self, S):
		vow = ['a', 'e', 'i', 'o', 'u']
		c = v = 0
		for i in range(len(S)):
			if S[i] in vow:
				c = 0
				v += 1
				if v > 5:
					return 0
			elif S[i] not in vow and S[i] != '?':
				v = 0
				c += 1
				if c > 3:
					return 0
			elif S[i] == '?':
				v += 1
				c += 1
				if v > 5 or c > 3:
					return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = [ord('a'), ord('e'), ord('i'), ord('o'), ord('u')]
		alphaMax = ord('z')
		alphaMin = ord('a')
		vCount = 0
		cCount = 0
		result = 1
		for i in S:
			curr = ord(i)
			if curr > alphaMax or curr < alphaMin:
				vCount += 1
				cCount += 1
			elif curr in vowels:
				cCount = 0
				vCount += 1
			else:
				vCount = 0
				cCount += 1
			if cCount > 3 or vCount > 5:
				result = 0
				break
		return result


class Solution:

	def isGoodorBad(self, S):
		countv = 0
		countc = 0
		temp = 'aeiou'
		for i in S:
			if i == '?':
				countv = countv + 1
				countc = countc + 1
			elif i in temp:
				countv = countv + 1
				countc = 0
			else:
				countc = countc + 1
				countv = 0
			if countv > 5 or countc > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = 'aeiou'
		consonants = 'bcdfghjklmnpqrstvwxyz'
		vCount = 0
		cCount = 0
		for i in S:
			if i in vowels:
				vCount += 1
				cCount = 0
			elif i in consonants:
				cCount += 1
				vCount = 0
			elif i == '?':
				vCount += 1
				cCount += 1
			if cCount > 3 or vCount > 5:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vol = 0
		con = 0
		vowels = 'aeiou'
		for i in S:
			if vol > 5 or con > 3:
				return 0
			elif i == '?':
				vol += 1
				con += 1
			elif i in vowels:
				vol += 1
				con = 0
			else:
				con += 1
				vol = 0
		if vol > 5 or con > 3:
			return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		vowels = 'aeiou'
		vcount = 0
		ccount = 0
		for e in S:
			if e == '?':
				vcount += 1
				ccount += 1
			elif e in vowels:
				vcount += 1
				ccount = 0
			else:
				ccount += 1
				vcount = 0
			if ccount > 3 or vcount > 5:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		con = 0
		vov = 0
		for i in S:
			if i in ['a', 'e', 'i', 'o', 'u']:
				con = 0
				vov += 1
			elif i == '?':
				con += 1
				vov += 1
			else:
				con += 1
				vov = 0
			if vov > 5 or con > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		new = []
		res = ''
		for i in S:
			if i in 'aeiou?':
				res += i
			else:
				if len(res) > 5:
					new.append(res)
				res = ''
		if len(res) > 5:
			new.append(res)
		tem = ''
		for i in S:
			if i in 'bcdfghjklmnpqrstvwxyz?':
				tem += i
			else:
				if len(tem) > 3:
					new.append(tem)
				tem = ''
		if len(tem) > 3:
			new.append(tem)
		if len(new) > 0:
			return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, s):
		v = 0
		c = 0
		for i in s:
			if (i == 'a' or i == 'e' or i == 'i' or (i == 'o') or (i == 'u')) or (v != 0 and i == '?'):
				v += 1
				c = 0
			elif i != 'a' and i != 'e' and (i != 'i') and (i != 'o') and (i != 'u') or (c != 0 and i == '?'):
				c += 1
				v = 0
			if c > 3:
				return 0
			elif v > 5:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		v = 'aeiou'
		vc = 0
		cc = 0
		for char in S:
			if char == '?':
				vc += 1
				cc += 1
			elif char in v:
				vc += 1
				cc = 0
			else:
				cc += 1
				vc = 0
			if cc == 4 or vc == 6:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		i = 0
		j = 0
		k = 0
		l = 0
		for i in range(0, len(S)):
			if S[i] == 'a' or S[i] == 'i' or S[i] == 'e' or (S[i] == 'o') or (S[i] == 'u'):
				k = k + 1
				l = 0
			elif S[i] == '?':
				if k > l:
					k = k + 1
					l = 0
				else:
					k = 0
					l = l + 1
			else:
				l = l + 1
				k = 0
			if l > 3 or k > 5:
				j = 1
		if j != 1:
			return 1
		else:
			return 0


class Solution:

	def isGoodorBad(self, S):
		c = 0
		v = 0
		for i in range(len(S)):
			if S[i] == 'a' or S[i] == 'e' or S[i] == 'i' or (S[i] == 'o') or (S[i] == 'u'):
				v += 1
				c = 0
			else:
				v = 0
				c += 1
			if c > 3 or v > 5:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		s1 = 0
		s2 = 0
		n = len(S)
		for i in range(0, n):
			if S[i] == 'a' or S[i] == 'e' or S[i] == 'i' or (S[i] == 'o') or (S[i] == 'u'):
				s1 = s1 + 1
				s2 = 0
			else:
				s2 = s2 + 1
				s1 = 0
			if s1 > 5 or s2 > 3:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		s = 0
		s1 = 0
		vow = 'aeiou'
		for i in S:
			if i in vow or i == '?':
				s += 1
				if s > 5:
					return 0
			else:
				s = 0
			if i not in vow or i == '?':
				s1 += 1
				if s1 > 3:
					return 0
			else:
				s1 = 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		Vol = 'aeiou'
		sy = '?!'
		v = 0
		c = 0
		for i in S:
			if i in Vol:
				v += 1
				c = 0
			elif i in sy:
				v += 1
				c += 1
			else:
				c += 1
				v = 0
			if v > 5 or c > 3:
				return 0


class Solution:

	def isGoodorBad(self, S):
		v = ['a', 'e', 'i', 'o', 'u']
		c = 1
		for i in range(0, len(S) - 3):
			if S[i] not in v and S[i + 1] not in v and (S[i + 2] not in v) and (S[i + 3] not in v):
				c = 0
				break
		if S.__contains__('aeiou??') or c == 0:
			return 0
		else:
			return 1


class Solution:

	def isGoodorBad(self, S):
		v = 'aeiou'
		vo = 0
		co = 0
		for c in S:
			if c == '?':
				vo += 1
				co += 1
			elif c in v:
				vo += 1
				co = 0
			else:
				co += 1
				vo = 0
			if co == 4 or vo == 6:
				return 0
		return 1


class Solution:

	def isGoodorBad(self, S):
		c = 0
		c1 = 0
		v = 'aeiou'
		for i in S:
			if i == '?':
				c += 1
				c1 += 1
			elif i in v:
				c += 1
				c1 = 0
				if c > 5:
					return 0
			else:
				c1 += 1
				c = 0
				if c1 > 3:
					return 0
		return 1