Leetcode-dfs & bfs

102. 二叉树的层次遍历 https://leetcode-cn.com/problems/binary-tree-level-order-traversal/html 给定一个二叉树,返回其按层次遍历的节点值。 (即逐层地,从左到右访问全部节点)。node 解:python 利用队列实现bfs,从根节点开始入队,若是左右子树不空,就入队。把每层的全部节点都遍历完了,下一层的最左节点再出队。(用
相关文章
相关标签/搜索