题目描述
1 |
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. |
解题思路
使用深度遍历的方式进行解决。
Go实现
1 |
func (root *TreeNode, target int, sum int) bool{ |
1 |
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. |
使用深度遍历的方式进行解决。
1 |
func (root *TreeNode, target int, sum int) bool{ |
近期评论