




from __future__ import annotations





def __UpperCamelCase			(       _A ,  _A  ):
						lowerCAmelCase_      			=  get_failure_array(_A  )

						# 2) Step through text searching for pattern
						lowerCAmelCase_			,					lowerCAmelCase_      			=  0, 0  # index into text, pattern
						while i < len(_A  ):
												if pattern[j] == text[i]:
																		if j == (len(_A  ) - 1):
																								return True
																		j += 1

												# if this is a prefix in our pattern
												# just go back far enough to continue
												elif j > 0:
																		lowerCAmelCase_      			=  failure[j - 1]
																		continue
												i += 1
						return False





def __UpperCamelCase			(       _A  ):
						lowerCAmelCase_      			=  [0]
						lowerCAmelCase_      			=  0
						lowerCAmelCase_      			=  1
						while j < len(_A  ):
												if pattern[i] == pattern[j]:
																		i += 1
												elif i > 0:
																		lowerCAmelCase_      			=  failure[i - 1]
																		continue
												j += 1
												failure.append(_A  )
						return failure


if __name__ == "__main__":
						# Test 1)
						_A     =			'''abc1abc12'''
						_A     =			'''alskfjaldsabc1abc1abc12k23adsfabcabc'''
						_A     =			'''alskfjaldsk23adsfabcabc'''
						assert kmp(pattern, texta) and not kmp(pattern, texta)

						# Test 2)
						_A     =			'''ABABX'''
						_A     =			'''ABABZABABYABABX'''
						assert kmp(pattern, text)

						# Test 3)
						_A     =			'''AAAB'''
						_A     =			'''ABAAAAAB'''
						assert kmp(pattern, text)

						# Test 4)
						_A     =			'''abcdabcy'''
						_A     =			'''abcxabcdabxabcdabcdabcy'''
						assert kmp(pattern, text)

						# Test 5)
						_A     =			'''aabaabaaa'''
						assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]










def __UpperCamelCase			(       _A  ):
						if not numbers:
												return 0

						if not isinstance(_A ,  (list, tuple)  ) or not all(
						    isinstance(_A ,  _A  ) for number in numbers  ):
												raise ValueError('''numbers must be an iterable of integers'''  )

						lowerCAmelCase_      			=  lowerCAmelCase_      			=  lowerCAmelCase_      			=  numbers[0]

						for i in range(1 ,  len(_A  )  ):
												# update the maximum and minimum subarray products
												lowerCAmelCase_      			=  numbers[i]
												if number < 0:
																		lowerCAmelCase_			,					lowerCAmelCase_      			=  min_till_now, max_till_now
												lowerCAmelCase_      			=  max(_A ,  max_till_now * number  )
												lowerCAmelCase_      			=  min(_A ,  min_till_now * number  )

												# update the maximum product found till now
												lowerCAmelCase_      			=  max(_A ,  _A  )

						return max_prod




