Problem
Given a binary tree, return the inorder traversal of its nodes’ values.
Example
1 | Input: [1,null,2,3] |
Solution
Method: Recursive
Time Complexity: O(n)
Space Complexity: O(n)
1 | # Definition for a binary tree node. |
or
1 | def recursive(self, root): |
Solution2
Method: Depth First Search
Time Complexity: O(n)
Space Complexity: O(n)
1 | class Solution: |