Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. Note: A leaf is a node with no children.
(二叉树路径和并返回相应路径)
Example:
1. 递归
这道题是很清晰的递归的问题,需要注意的是节点的值可能是负值。具体实现方法如下:
1 | # Definition for a binary tree node. |