{"size": 584, "ext": "js", "max_stars_repo_path": "backlog/958.check-completeness-of-a-binary-tree.js", "max_stars_repo_name": "Sunalways/leetcode", "max_stars_repo_stars_event_min_datetime": "2019-09-04T01:48:55.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-02T16:01:53.000Z", "max_issues_repo_path": "backlog/958.check-completeness-of-a-binary-tree.js", "max_issues_repo_name": "Beanza/leetcode", "max_issues_repo_issues_event_min_datetime": "2015-07-13T11:43:38.000Z", "max_issues_repo_issues_event_max_datetime": "2015-07-21T10:55:15.000Z", "max_forks_repo_path": "backlog/958.check-completeness-of-a-binary-tree.js", "max_forks_repo_name": "Beanza/leetcode", "max_forks_repo_forks_event_min_datetime": "2019-08-28T15:00:47.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-17T03:05:06.000Z"}
{"max_stars_count": 17, "max_issues_count": 3, "max_forks_count": 12, "avg_line_length": 18.8387096774, "max_line_length": 46, "alphanum_fraction": 0.5667808219}
/*
 * @lc app=leetcode id=958 lang=javascript
 *
 * [958] Check Completeness of a Binary Tree
 */
/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var isCompleteTree = function(root) {
    if (root === null) return root;
    let cur = root;
    const queue = [];

    while(cur !== null) {
        queue.push(cur.left);
        queue.push(cur.right);
        cur = queue.shift();
    }

    return queue.filter(Boolean).length === 0;
};

