Function repeated_word(string) finds the first repeated word using a custom hash table.
Time Complexity: O(m + n) Space Complexity: O((m, n))
def tree_intersection(tree1,tree2):
check= HashTable()
array = []
def _walk(root,num=0):
# root
if num ==0:
check.set(root.value,root.value)
else:
if check.has(root.value) :
array.append(root.value)
# left
if root.left:
_walk(root.left,num)
# right
if root.right:
_walk(root.right, num)
_walk(tree1.root, 0)
_walk(tree2.root, 1)
return array