Created
December 6, 2021 10:32
-
-
Save haase1020/ff57c52e901702e8a142ff32390f4432 to your computer and use it in GitHub Desktop.
binary tree inorder traversal
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
// https://leetcode.com/problems/binary-tree-inorder-traversal/ | |
const dft = (root, result) => { | |
if (!root) return; | |
dft(root.left, result); | |
result.push(root.val); | |
dft(root.right, result); | |
return result; | |
}; | |
const inorderTraversal = (root) => { | |
const result = []; | |
dft(root, result); // recursive call made to other function | |
return result; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment