






"""simple docstring"""



def 		lowercase       (							__snake_case							:					Optional[int]      ):
		if not head:
				return True
		# split the list to two parts
		lowercase_			,   lowercase_					:					Optional[Any]							=  head.next, head
		while fast and fast.next:
				lowercase_					:					int							=  fast.next.next
				lowercase_					:					Optional[Any]							=  slow.next
		lowercase_					:					Dict							=  slow.next
		lowercase_					:					Any							=  None  # Don't forget here! But forget still works!
		# reverse the second part
		lowercase_					:					int							=  None
		while second:
				lowercase_					:					str							=  second.next
				lowercase_					:					Tuple							=  node
				lowercase_					:					Dict							=  second
				lowercase_					:					Optional[Any]							=  nxt
		# compare two parts
		# second part has the same or one less node
		while node:
				if node.val != head.val:
						return False
				lowercase_					:					Dict							=  node.next
				lowercase_					:					int							=  head.next
		return True



def 		lowercase       (							__snake_case							:					List[Any]      ):
		if not head or not head.next:
				return True

		# 1. Get the midpoint (slow)
		lowercase_					:					str							=  head
		while fast and fast.next:
				lowercase_			,   lowercase_					:					Tuple							=  fast.next.next, slow.next

		# 2. Push the second half into the stack
		lowercase_					:					Optional[Any]							=  [slow.val]
		while slow.next:
				lowercase_					:					List[Any]							=  slow.next
				stack.append(slow.val      )

		# 3. Comparison
		while stack:
				if stack.pop() != cur.val:
						return False
				lowercase_					:					List[Any]							=  cur.next

		return True






def 		lowercase       (							__snake_case							:					Dict      ):
		if not head or not head.next:
				return True
		lowercase_					:					Any							=  {}
		lowercase_					:					Union[str, Any]							=  0
		while head:
				if head.val in d:
						d[head.val].append(_lowerCamelCase      )
				else:
						lowercase_					:					Optional[Any]							=  [pos]
				lowercase_					:					Optional[int]							=  head.next
				pos += 1
		lowercase_					:					int							=  pos - 1
		lowercase_					:					Union[str, Any]							=  0
		for v in d.values():
				if len(_lowerCamelCase      ) % 2 != 0:
						middle += 1
				else:
						lowercase_					:					List[str]							=  0
						for i in range(0						,   len(_lowerCamelCase      )      ):
								if v[i] + v[len(_lowerCamelCase      ) - 1 - step] != checksum:
										return False
								step += 1
				if middle > 1:
						return False
		return True











"""simple docstring"""





import functools
from typing import Any







def 	lowerCamelCase__			(				_lowerCamelCase			:						str						,							_lowerCamelCase			:						list[str]					) ->							bool:

  # Validation
  if not isinstance(_lowerCamelCase						,							_lowerCamelCase					) or len(_lowerCamelCase					) == 0:
    raise ValueError('the string should be not empty string'					)

  if not isinstance(_lowerCamelCase						,							_lowerCamelCase					) or not all(
      isinstance(_lowerCamelCase						,							_lowerCamelCase					) and len(_lowerCamelCase					) > 0 for item in words					):
    raise ValueError('the words should be a list of non-empty strings'					)

  # Build trie
  lowerCamelCase_       	=		{}
  lowerCamelCase_       	=		'WORD_KEEPER'

  for word in words:
    lowerCamelCase_       	=		trie
    for c in word:
      if c not in trie_node:
        lowerCamelCase_       	=		{}

      lowerCamelCase_       	=		trie_node[c]

    lowerCamelCase_       	=		True

  lowerCamelCase_       	=		len(_lowerCamelCase					)

  # Dynamic programming method
  @functools.cache
  def is_breakable(_lowerCamelCase			:						int					) -> bool:
    if index == len_string:
      return True

    lowerCamelCase_       	=		trie
    for i in range(_lowerCamelCase						,							_lowerCamelCase					):
      lowerCamelCase_       	=		trie_node.get(string[i]						,							_lowerCamelCase					)

      if trie_node is None:
        return False

      if trie_node.get(_lowerCamelCase						,							_lowerCamelCase					) and is_breakable(i + 1					):
        return True

    return False

  return is_breakable(0					)


if __name__ == "__main__":
  import doctest

  doctest.testmod()




