246.Binary Tree Path Sum II
1.Description(Easy)
Your are given a binary tree in which each node contains a value. Design an algorithm to get all paths which sum to a given value. The path does not need to start or end at the root or a leaf, but it must go in a straight line down.
Example
Given a binary tree:
for target =6
, return
2.Code
Version 1:Recursive
Version 2: Iterative
Last updated