用 BFS 返回二叉树右视图(每层最右节点),横线处依次应填入:
nodeQueue.push(node->left); nodeQueue.push(node->right);
depthQueue.push(________); // depth+1
depthQueue.push(________); // depth+1
...
for (int depth=0; ________; ++depth) // depth <= max_depth
rightView.push_back(rightmostValueAtDepth[depth]);
- A. depth / depth / depth < max_depth
- B. depth+1 / depth+1 / depth <= max_depth
- C. depth+1 / depth+1 / depth < max_depth
- D. depth / depth / depth <= max_depth
正确答案:B