0%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
class Solution: def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]: list_ = [] stack = [] while stack !=[] or root != None: while root: stack.append(root) root = root.left if stack != []: temp_node = stack.pop() list_ += [temp_node.val] root = temp_node.right return list_
|