最新 最热

Leetcode 144 Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 2 / 3 return [1,...

2018-01-12
1

Leetcode 226. Invert Binary Tree

Invert a binary tree. 4 / 2 7 / / 1 3 6 9to 4 / 7 2 / / 9 6 3 1Trivia:This problem was inspired by...

2018-01-12
1

Leetcode 257. Binary Tree Paths

Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / 2 3 5 All root-to-leaf paths are:["1-...

2018-01-12
1

LeetCode: 102_Binary Tree Level Order Traversal | 二叉树自顶向下的层次遍历 | Easy

题目:Binay Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nod

2018-01-11
1

LeetCode:144_Binary Tree Preorder Traversal | 二叉树的前序遍历 | Medium

题目:Binary Tree Preorder Traversal二叉树的前序遍历,同样使用栈来解,代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* right; 5......

2018-01-11
1

LeetCode:94_Binary Tree Inorder Traversal | 二叉树中序遍历 | Medium

题目:Binary Tree Inorder Traversal二叉树的中序遍历,和前序、中序一样的处理方式,代码见下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* righ......

2018-01-11
1

LWC 51:684. Redundant Connection

该文讲述了如何检测并删除树中冗余的边,以保证树的连通性。首先介绍了并查集,用于检查节点是否属于同一个连通块;然后讲述了如何通过并查集检测冗余边,并返回最后出现在2D数组中的边,保证至少存在一条有效边。...

2018-01-02
1

POJ 刷题系列:2255. Tree Recovery

该文介绍了如何通过递归思想,使用一个递归函数构建一棵树,并利用一个数组来记录每个节点的值。在遍历树的过程中,每当遍历到一个节点时,都会将它的值写入数组中。最后,将数组转换为字符串,即可得到一棵完整的二叉树。...

2018-01-02
0