归档 2015年8月16日

[LeetCode]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->2->5", "1->3"]

题目大意:

给定一棵二叉树,返回所有“根到叶子”的路径。

例如,给定下面的二叉树:

   1
 /   \
2     3
 \
  5

所有“根到叶子”路径为:

["1->2->5", "1->3"]

解题思路:

树的遍历 ...

继续阅读

昨天

明天

归档