Skip to content

Commit a08068b

Browse files
committedSep 9, 2022
Time: 101 ms (28.09%), Space: 42.2 MB (55.16%) - LeetHub
1 parent 1119d6e commit a08068b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* function TreeNode(val, left, right) {
4+
* this.val = (val===undefined ? 0 : val)
5+
* this.left = (left===undefined ? null : left)
6+
* this.right = (right===undefined ? null : right)
7+
* }
8+
*/
9+
/**
10+
* @param {TreeNode} root
11+
* @return {number[]}
12+
*/
13+
14+
15+
const inorder = (root, ans ) => {
16+
if(root === null) return;
17+
inorder(root.left, ans);
18+
ans.push(root.val);
19+
inorder(root.right, ans);
20+
}
21+
22+
var inorderTraversal = function(root) {
23+
const ans = [];
24+
inorder(root, ans);
25+
return ans;
26+
};

0 commit comments

Comments
 (0)
Please sign in to comment.