Skip to content
C

Check Balanced Binary Tree

Mediumjavapythonccppjavascript

Determine whether a binary tree is height-balanced: for every node, the heights of its left and right subtrees differ by at most 1.

Input Format

The first line contains an integer M, the number of level-order tokens. The second line contains M space-separated tokens (integers or null). It is blank when M is 0.

Output Format

Print 1 if the tree is balanced, otherwise print 0.

Input (stdin)

Output

Run your code to see output here...