题目如下: 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 resp ...
分类:
其他好文 时间:
2019-02-26 10:34:18
阅读次数:
104
1、题目描述 2、问题分析 采用递归方法是标准解法。 3、代码 ...
分类:
其他好文 时间:
2019-02-23 21:53:43
阅读次数:
189
#include #define read read() #define up(i,l,r) for(register int i = (l);i = (r);i--) #define traversal_vedge(i) for(register int i = head[u]; i ;i = e... ...
分类:
其他好文 时间:
2019-02-21 20:19:34
阅读次数:
201
题目描述 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
传送门 题目大意 给出一棵无根树,每个节点有一个权值,现在要让dfs序的前k个结点的最小值最大,求出这个值。分析 首先可以对这个值v进行二分然后01分数规划现在问题转化为求出一个dfs序,使得dfs序中的至少有k个1,这一步可以用树形dp来做。用dp[u]表示从节点u开始在子树中进行dfs最多可以经 ...
分类:
其他好文 时间:
2019-02-11 12:21:46
阅读次数:
158
题目要求 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