LeetCode p257 Binary Tree Paths 题解
1.题目:
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->2->5”, “1->3”]
题意:
输出一个二叉树包含的所有的路径。
2.解题思路:
见代码
3.代码
1 |
|