Created
June 6, 2021 09:16
-
-
Save vmarois/917491d682aa65f90c3af099909fc2bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dfs(root: TreeNode) -> TreeNode: | |
stack = [] | |
while root or stack: | |
while root: | |
stack.append(root) | |
root = root.left | |
root = stack.pop() | |
print('Processing {}'.format(root.val)) | |
root = root.right |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment