filmov
tv
LeetCode 94. Binary Tree Inorder Traversal Javascript Python

Показать описание
Leetcode easy to hard.
forgot to add the python solution
here it is recursively.
each time we call the function to left most node then start appending values to the result array.
Think of the stack of recursive calls.
class Solution:
def inorderTraversal(self, root):
results = []
def dfs(node):
if not node:
return
dfs(root)
return results
forgot to add the python solution
here it is recursively.
each time we call the function to left most node then start appending values to the result array.
Think of the stack of recursive calls.
class Solution:
def inorderTraversal(self, root):
results = []
def dfs(node):
if not node:
return
dfs(root)
return results