2
* Definition for a binary tree node.3
* function TreeNode(val, left, right) {4
* this.val = (val===undefined ? 0 : val)5
* this.left = (left===undefined ? null : left)6
* this.right = (right===undefined ? null : right)10
* @param {TreeNode} root13
var widthOfBinaryTree = function (root) {18
while (row.length > 0) {22
for (let i = 0; i < row.length; i++) {23
const [node, index] = row[i];24
if (curStart === -1) {31
nextRow.push([node.left, index * 2]);35
nextRow.push([node.right, index * 2 + 1]);39
res = Math.max(res, curEnd - curStart + 1);40
if (nextRow.length === 1) {