Binary Tree Paths
Question
Given a binary tree, return all root-to-leaf paths.
Example:
For example, given the following binary tree:
All root-to-leaf paths are:
Answer
solution:
Knowledge:
这道题目与之前的层遍历不同,是需要按照路径遍历。遍历树问题——按路径遍历(迭代),记住remember该方法。
Last updated
Was this helpful?