#C11521. Maximum Width of a Binary Tree

    ID: 40847 Type: Default 1000ms 256MiB

Maximum Width of a Binary Tree

Maximum Width of a Binary Tree

You are given an array that represents a binary tree in level order (1-indexed). In this representation, each element corresponds to a node's value, and a value of (-1) indicates a null node. The width of the tree is defined as the maximum number of non-null nodes present at any level. Your task is to determine the maximum width of the binary tree.

The binary tree is represented as an array where the left child of the node at index (i) is at index (2i) and the right child is at index (2i+1), considering 1-indexed positions within the array. Note that the array will contain at least 1 and at most 100 integers, and each integer is between (-1) and 1000, inclusive.

inputFormat

Input is given as a single line containing space-separated integers that represent the binary tree in level order. A value of (-1) indicates that the node is null.

outputFormat

Output a single integer representing the maximum width of the binary tree.## sample

1 2 3 4 5 6 7 -1 -1 -1 -1 -1 -1 8 -1
4

</p>