Skip to content

Added Python solution for 94.Binary Tree InOrder Traversal #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Algorithms/Easy/94_BinaryTreeInorderTraversal/Solution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Solution:
def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
stack = []
output_array = []

if root is None:
return output_array

current = root

while current is not None or stack:
while current is not None:
stack.append(current)
current = current.left

current = stack.pop()
output_array.append(current.val)
current = current.right

return output_array