#1164. 二叉树叶子序列
二叉树叶子序列
Cannot parse: (0 , import_utils.normalizeSubtasks) is not a function or its return value is not iterable
Background
Special for beginners, ^_^
Description
你将获得一棵 n 个结点的二叉树,请按前序遍历,或中序遍历,或后续遍历的顺序,输出二叉树的叶子结点序列。
注意根节点永远是 1
Format
Input
输入第一行一个整数 n 表示结点数量
第二行开始的 n - 1 行,每行两个整数 u,v,表示 u 号结点时 v 结点的父亲。
注意 u 作为父亲的第一次,一定是指左孩子的情况。
Output
一行若干整数序列,表示按要求遍历的叶子结点序列
Samples
10
1 2
1 6
2 3
2 4
4 5
4 7
5 8
5 10
8 9
3 9 10 7 6
Limitation
1s, 1024KiB for each test case...
Related
In following contests: