Skip to content

Commit 3056234

Browse files
authored
Added Python solution for 94.Binary Tree InOrder Traversal (#129)
1 parent d933d22 commit 3056234

File tree

1 file changed

+20
-0
lines changed
  • Algorithms/Easy/94_BinaryTreeInorderTraversal

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
3+
stack = []
4+
output_array = []
5+
6+
if root is None:
7+
return output_array
8+
9+
current = root
10+
11+
while current is not None or stack:
12+
while current is not None:
13+
stack.append(current)
14+
current = current.left
15+
16+
current = stack.pop()
17+
output_array.append(current.val)
18+
current = current.right
19+
20+
return output_array

0 commit comments

Comments
 (0)