Open unliar opened 3 years ago
const countNodes = function (root) { if (!root) return 0; const queqe = [root]; let count = 0; while (queqe.length > 0) { let p = queqe.shift(); count++; if (p.left) queqe.push(p.left); if (p.right) queqe.push(p.right); } return count; };