Question
Given a binary tree, return all root-to-leaf paths.
For example, given the following binary tree:
All root-to-leaf paths are:
Explanation
分治法,只用考虑左右子树会出现的情况就好了。另外此处注意叶子节点,就不用加“->”了。
Given a binary tree, return all root-to-leaf paths.
For example, given the following binary tree:
All root-to-leaf paths are:
分治法,只用考虑左右子树会出现的情况就好了。另外此处注意叶子节点,就不用加“->”了。