#K86257. Balanced Binary Tree

    ID: 36824 Type: Default 1000ms 256MiB

Balanced Binary Tree

Balanced Binary Tree

You are given a binary tree represented as a comma separated string in level order. Each element represents a node's value. The keyword None represents a missing node.

A binary tree is defined to be balanced if for every node, the absolute difference between the heights of the left subtree and the right subtree is at most one. In mathematical notation, a node is balanced if

\( |h_{left} - h_{right}| \le 1 \)

Your task is to determine whether the given binary tree is balanced.

Note: The input is provided as a single line from the standard input (stdin) and the output should be printed to the standard output (stdout) as either True or False.

inputFormat

The input consists of a single line containing a comma separated string representing the binary tree in level order. Use the string None (case sensitive) to indicate an absent child.

Example:

3,9,20,None,None,15,7

outputFormat

Output a single line: True if the tree is balanced, and False otherwise.

## sample
1,2,2,3,3,None,None,4,4
False