129. Sum Root to Leaf Numbers
# Medium
BFS, two ways: sum = sum*10 + root.val
Queue + while loop
Recursive
x = queue.front(), 队结构先进先出,queue.pop() 弹出第一个元素,这两是一对。
Solution 1: update evey node's value with path sum from root to this node
Solution 2: subTree(root, sum)
means sum path from root to all leaves, including root.
subTree(root, sum)
means sum path from root to all leaves, including root.Last updated