文章 2016-01-22 来自:开发者社区

LeetCode 102 Binary Tree Level Order Traversal(二叉树的层级顺序遍历)(*)

版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/50560214 翻译 给定一个二叉树,返回按层级顺序遍历的每个节点的值。 从左到右,逐层遍历。 例如: ...

文章 2016-01-22 来自:开发者社区

LeetCode 107 Binary Tree Level Order Traversal II(二叉树的层级顺序遍历2)(*)

版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/50560004 翻译 给定一个二叉树,返回从下往上遍历经过的每个节点的值。 从左往右,从叶子到节点。 例...

文章 2015-09-11 来自:开发者社区

[LeetCode] Binary Tree Level Order Traversal 二叉树层次遍历(DFS | BFS)

目录:1.Binary Tree Level Order Traversal - 二叉树层次遍历 BFS 2.Binary Tree Level Order Traversal II - 二叉树层次遍历从低往高输出 BFS 3.Maximum Depth of Binary Tree - 求二叉树的深度 DFS4.Balanced Binary Tree - 判断平衡二叉树 DFS5.Path ....

文章 2015-07-14 来自:开发者社区

leetcode 102 Binary Tree Level Order Traversal

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ ...

文章 2015-07-04 来自:开发者社区

[LeetCode] Binary Tree Zigzag Level Order Traversal

To be honest, I do not know whether this problem is designed to let you use stacks. Anyway, I don't. Here are my codes, both BFS and DFS version. 1 // BFS 2 vector<vector<int>>...

文章 2015-06-02 来自:开发者社区

[LeetCode] Binary Tree Level Order Traversal II

Well, I do not see what this problem is for. The same code of Binary Tree Level Order Traversal can be used here. The only difference is that we should reverse the result before we return.  Again...

文章 2015-06-02 来自:开发者社区

[LeetCode] Binary Tree Level Order Traversal

A classic tree traversal problem. I share my two solutions here: BFS and DFS. BFS: 1 vector<vector<int>> levelOrder(TreeNode *root) { 2 vector<vector<int>> leve...

文章 2015-06-02 来自:开发者社区

[LeetCode] Binary Tree Postorder Traversal

This is a fundamental and yet classic problem. I share my three solutions here: Iterative solution using stack --- O(n) time and O(n) space; Recursive solution --- O(n) t...

文章 2015-06-02 来自:开发者社区

[LeetCode] Binary Tree Inorder Traversal

This is a fundamental and yet classic problem. I share my three solutions here: Iterative solution using stack --- O(n) time and O(n) space; Recursive solution --- O(n) t...

文章 2015-06-02 来自:开发者社区

[LeetCode] Binary Tree Preorder Traversal

This is a fundamental and yet classic problem. I share my three solutions here: Iterative solution using stack --- O(n) time and O(n) space; Recursive solution --- O(n) t...

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

算法编程

开发者社区在线编程频道官方技术圈。包含算法资源更新,周赛动态,每日一题互动。

+关注