Skip to content

Commit 860f6ad

Browse files
committed
Time: 45 ms (89.06%), Space: 49.2 MB (19.89%) - LeetHub
1 parent 8d65f00 commit 860f6ad

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
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+
/**
11+
* @param {TreeNode} root
12+
* @return {number[]}
13+
*/
14+
15+
var inorderTraversal = function(root) {
16+
const result = [];
17+
function inorder(node) {
18+
if (node) {
19+
inorder(node.left);
20+
result.push(node.val);
21+
inorder(node.right);
22+
}
23+
}
24+
inorder(root);
25+
return result;
26+
};

0 commit comments

Comments
 (0)