MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / Solution

Class Solution

Python/Iterative-Inorder-tree-traversal.py:7–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5# self.left = left
6# self.right = right
7class Solution:
8 def inorderTraversal(self, root: TreeNode) -> List[int]:
9 if not root:
10 return []
11 result = []
12 stack = []
13 node = root
14 while stack or node:
15 while node:
16 stack.append(node)
17 node = node.left
18 node = stack.pop()
19 result.append(node.val)
20 node = node.right
21 return result
22
23

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected