Practice Check Completeness of a Binary Tree
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Return whether the binary tree is complete. Every level before the final one must be full, and final-level nodes must occupy the leftmost positions without gaps. If the last level is h edges below the root, it can contain from 1 through 2^h nodes.
Source: Check Completeness of a Binary Tree on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
root = [1,2,3,4,5,6]
Output
true
# Example 2
Input
root = [1,2,3,4,5,null,7]
Output
false
Constraints
The number of nodes in the tree is in the range [1, 100].
1 <= Node.val <= 1000
Related LeetCode Problems
Practice more problems similar to Check Completeness of a Binary Tree.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.