题目描述 The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a ...
分类:
其他好文 时间:
2019-02-16 15:39:54
阅读次数:
191
1. Traverse the binary tree, store {x,y,val} for every node in records; 2. Sort the records of {x,y,val} for all nodes by increasing x, decreasing y, ...
分类:
其他好文 时间:
2019-02-12 21:45:45
阅读次数:
133
https://pintia.cn/problem-sets/994805342720868352/problems/994805380754817024 An inorder binary tree traversal can be implemented in a non-recursive w ...
分类:
其他好文 时间:
2019-02-12 13:16:46
阅读次数:
110
题目要求 Given an n-ary tree, return the preorder traversal of its nodes' values. 题目分析及思路 题目给出一棵N叉树,要求返回结点值的前序遍历。可以使用递归的方法做。因为是前序遍历,所以最开始就加入根结点的值。 python代 ...
分类:
其他好文 时间:
2019-02-10 10:55:16
阅读次数:
144
Given a binary tree, return the vertical order traversal of its nodes values. For each node at position (X, Y), its left and right children respective ...
分类:
其他好文 时间:
2019-02-10 10:54:33
阅读次数:
306
1.二叉树 BFS 2.拓扑排序 重点 BFS 3.棋盘上的宽搜 BFS 图的遍历 层级遍历,由点及面,拓扑排序,简单图的最短路径 如果题目问最短路径:可能是BFS或者DP, 最长路径:DFS queue 的数组实现 1.二叉树的BFS https://www.lintcode.com/proble ...
分类:
其他好文 时间:
2019-02-07 09:36:35
阅读次数:
178
算法描述: Given a binary tree, return the preorder traversal of its nodes' values. Example: Follow up: Recursive solution is trivial, could you do it iter ...
分类:
其他好文 时间:
2019-02-06 18:35:55
阅读次数:
109
算法描述: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For exa ...
分类:
其他好文 时间:
2019-02-03 11:08:11
阅读次数:
193
算法描述: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For ex ...
分类:
其他好文 时间:
2019-02-03 10:41:35
阅读次数:
198
算法描述: 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 t ...
分类:
其他好文 时间:
2019-02-03 10:40:28
阅读次数:
184