Write a function called tree_intersection that takes two binary trees as parameters and return a set of values found in both trees.
Method | Time Complexity | Space Complexity |
---|---|---|
preOrder | O(n) | O(n) |
treeIntersection | O(n) | O(n) |
Write a function called tree_intersection that takes two binary trees as parameters and return a set of values found in both trees.
Method | Time Complexity | Space Complexity |
---|---|---|
preOrder | O(n) | O(n) |
treeIntersection | O(n) | O(n) |