





"""simple docstring"""






from __future__ import annotations

from collections import deque
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Any




@dataclass
class 					__lowercase      :







					'''simple docstring'''




					__lowerCAmelCase	=	42
					__lowerCAmelCase	=	None
					__lowerCAmelCase	=	None






def      __A   (      )		->		Node | None:
				__a			:    List[str]      							=	Node(1)
				__a			:    Any      							=	Node(2)
				__a			:    Tuple      							=	Node(3)
				__a			:    str      							=	Node(4)
				__a			:    Dict      							=	Node(5)
				return tree

def      __A   (      a_    :Node | None)		->		list[int]:
				return [root.data, *preorder(root.left), *preorder(root.right)] if root else []

def      __A   (      a_    :Node | None)		->		list[int]:
				return postorder(root.left) + postorder(root.right) + [root.data] if root else []

def      __A   (      a_    :Node | None)		->		list[int]:
				return [*inorder(root.left), root.data, *inorder(root.right)] if root else []

def      __A   (      a_    :Node | None)		->		int:
				return (max(height(root.left) ,							height(root.right)) + 1) if root else 0

def      __A   (      a_    :Node | None)		->		Sequence[Node | None]:
				__a			:    list[Any]      							=	[]

				if root is None:
								return output

				__a			:    List[Any]      							=	deque([root])

				while process_queue:
								__a			:    str      							=	process_queue.popleft()
								output.append(node.data)

								if node.left:
												process_queue.append(node.left)
								if node.right:
												process_queue.append(node.right)
				return output

def      __A   (      a_    :Node | None ,							a_    :int)		->		Sequence[Node | None]:
				__a			:    list[Any]      							=	[]

				def populate_output(a_    :Node | None ,							a_    :int) -> None:
								if not root:
												return
								if level == 1:
												output.append(root.data)
								elif level > 1:
												populate_output(root.left ,							level - 1)
												populate_output(root.right ,							level - 1)

				populate_output(a_ ,							a_)
				return output

def      __A   (      a_    :Node | None ,							a_    :int)		->		Sequence[Node | None]:
				__a			:    list[Any]      							=	[]

				def populate_output(a_    :Node | None ,							a_    :int) -> None:
								if root is None:
												return
								if level == 1:
												output.append(root.data)
								elif level > 1:
												populate_output(root.right ,							level - 1)
												populate_output(root.left ,							level - 1)

				populate_output(a_ ,							a_)
				return output

def      __A   (      a_    :Node | None)		->		Sequence[Node | None] | list[Any]:
				if root is None:
								return []

				__a			:    list[Sequence[Node | None]]      							=	[]

				__a			:    int      							=	0
				__a			:    Optional[int]      							=	height(a_)

				for h in range(1 ,							height_tree + 1):
								if not flag:
												output.append(get_nodes_from_left_to_right(a_ ,							a_))
												__a			:    Any      							=	1
								else:
												output.append(get_nodes_from_right_to_left(a_ ,							a_))
												__a			:    Optional[int]      							=	0

				return output

def      __A   (      )		->		None:  # Main function for testing.
				__a			:    str      							=	make_tree()
				print(F"""In-order Traversal: {inorder(a_)}""")
				print(F"""Pre-order Traversal: {preorder(a_)}""")
				print(F"""Post-order Traversal: {postorder(a_)}""" ,							'''\n''')

				print(F"""Height of Tree: {height(a_)}""" ,							'''\n''')

				print('''Complete Level Order Traversal: ''')
				print(level_order(a_) ,							'''\n''')

				print('''Level-wise order Traversal: ''')

				for level in range(1 ,							height(a_) + 1):
								print(F"""Level {level}:""" ,							get_nodes_from_left_to_right(a_ ,							level=a_))

				print('''\nZigZag order Traversal: ''')
				print(zigzag(a_))


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		main()





"""simple docstring"""




from collections.abc import Sequence



def        a__					(							snake_case__			,					snake_case__ = False							)		->   float:
			if not arr:
						return 0

			lowerCamelCase      =   0 if allow_empty_subarrays else float("""-inf"""							)
			lowerCamelCase      =   0.0
			for num in arr:
						lowerCamelCase      =   max(0 if allow_empty_subarrays else num			,					curr_sum + num							)
						lowerCamelCase      =   max(snake_case__			,					snake_case__							)

			return max_sum


if __name__ == "__main__":
					from doctest import testmod

					testmod()

					lowerCAmelCase				:     Union[str, Any]					=				[-2, 1, -3, 4, -1, 2, 1, -5, 4]
					print(F"""{max_subarray_sum(nums) = }""")



