Problem
Given a binary tree, return all root-to-leaf paths.
Example
1 | Input: |
Solution
Method: Depth-first Search
Time Complexity: O(n)
Space Complexity: O(n)
1 | # Definition for a binary tree node. |
Given a binary tree, return all root-to-leaf paths.
1 | Input: |
Method: Depth-first Search
Time Complexity: O(n)
Space Complexity: O(n)
1 | # Definition for a binary tree node. |