860. Check if Binary Tree is Full

EasyTreesBinary TreeDFSRecursion

Given the root of a binary tree, determine whether it is a full binary tree — every node has either zero or two children (no node has exactly one child). Return true or false. The tree is given as a level-order array with null for missing children.

Input: A level-order array of the tree.

Output: Boolean — true or false.

Examples

Example 1
Input: [1,2,3,4,5,6,7]
Output: true
Explanation: Every node has 0 or 2 children.
Example 2
Input: [1,2,null,3,4]
Output: false
Explanation: Node 2 has one child.
Example 3
Input: [1]
Output: true
Explanation: Single node (a leaf).

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →