Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.
 
Example 1:
Input: arr = [2,6,4,1]
Output: false
Explanation: There are no three consecutive odds.

Example 2:
Input: arr = [1,2,34,3,4,5,7,23,12]
Output: true
Explanation: [5,7,23] are three consecutive odds.

 
Constraints:

1 <= arr.length <= 1000
1 <= arr[i] <= 1000

Difficulty: EASY
Tags: Data structures
Skill types: Data structures

Starter code:
class Solution:
    def threeConsecutiveOdds(self, arr: List[int]) -> bool:
        

Solutions:
class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		flag = False
		odd = 0
		i = 0
		while i < len(arr):
			if arr[i] % 2 == 1:
				if not flag:
					flag = True
					odd += 1
					i += 1
				else:
					odd += 1
					i += 1
			elif not flag:
				i += 1
			else:
				flag = False
				odd = 0
				i += 1
			if odd == 3:
				return True
		return False


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		if len(arr) < 3:
			return False
		count = 0
		for i in arr:
			if i % 2 != 0:
				count += 1
			elif i % 2 == 0:
				count = 0
			if count == 3:
				return True
		return False


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		if len(arr) < 3:
			return False
		elif arr[0] % 2 + arr[1] % 2 + arr[2] % 2 == 3:
			return True
		else:
			return self.threeConsecutiveOdds(arr[1:])


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		for i in range(len(arr)):
			if arr[i] % 2 != 0:
				toCheck = arr[i:i + 3]
				print(toCheck)
				if len(toCheck) >= 3:
					if toCheck[1] % 2 != 0 and toCheck[2] % 2 != 0:
						return True
		return False


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		for i in range(len(arr) - 2):
			if self.is_odd(arr[i]) and self.is_odd(arr[i + 1]) and self.is_odd(arr[i + 2]):
				return True
		return False

	def is_odd(self, num):
		return num % 2 != 0


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		a = 0
		while a < len(arr) - 2:
			if arr[a] & 1 and arr[a + 1] & 1 and arr[a + 2] & 1:
				return True
			elif arr[a + 2] & 1 == 0:
				a += 3
			elif arr[a + 1] & 1 == 0:
				a += 2
			elif arr[a] & 1 == 0:
				a += 1
		return False


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		oddFound = False
		numOdd = 0
		for num in arr:
			if num % 2 != 0:
				oddFound = True
				numOdd += 1
				if numOdd == 3:
					return True
			else:
				oddFound = False
				numOdd = 0
		return False


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		number_of_cons_odds = 0
		for elem in arr:
			if elem % 2 == 0:
				number_of_cons_odds = 0
				continue
			number_of_cons_odds += 1
			if number_of_cons_odds == 3:
				return True
		return False


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		return any((arr[i] % 2 != 0 and arr[i + 1] % 2 != 0 and (arr[i + 2] % 2 != 0) for i in range(len(arr) - 2)))


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		inds = [n % 2 for n in arr]
		temp = []
		for (i, v) in enumerate(inds):
			if v == 1:
				temp.append(i)
		if len(temp) < 3:
			return False
		for i in range(1, len(temp) - 1):
			if temp[i] - temp[i - 1] == 1 and temp[i + 1] - temp[i] == 1:
				return True
		return False


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		odd1 = False
		odd2 = False
		for num in arr:
			if num % 2:
				if odd2:
					return True
				odd2 = odd1
				odd1 = True
			else:
				odd1 = False
				odd2 = False
		return False


class Solution:

	def threeConsecutiveOdds(self, arr: List[int]) -> bool:
		odds = 0
		for i in range(len(arr)):
			if arr[i] % 2 != 0:
				odds += 1
			else:
				odds = 0
			if odds >= 3:
				return True
		return False