3
bool isComplete = true;5
// Returns min, max height of node6
pair<int, int> helper(TreeNode *root) {7
// NULL is of height zero12
// Moving to its children13
pair<int, int> lst = helper(root->left);14
pair<int, int> rst = helper(root->right);16
// Height of rst is greater than lst or17
// There are levels which are not filled other than the last level (diff18
// between levels > 1)19
if (rst.second > lst.first || lst.second - rst.first > 1) {23
return {min(lst.first, rst.first) + 1, max(lst.second, rst.second) + 1};26
bool isCompleteTree(TreeNode *root) {