We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3cbf76e commit 11f4cdcCopy full SHA for 11f4cdc
Binary Tree Inorder Traversal/index.js
@@ -0,0 +1,31 @@
1
+/**
2
+ * Definition for a binary tree node.
3
+ * function TreeNode(val) {
4
+ * this.val = val;
5
+ * this.left = this.right = null;
6
+ * }
7
+ */
8
9
+ * @param {TreeNode} root
10
+ * @return {number[]}
11
12
+function inorderTraversal(root) {
13
+ const result = [];
14
+
15
+ return traversal(root, result);
16
+};
17
18
+function traversal(node, result) {
19
+ if (!node) return result;
20
+ if (node.left) {
21
+ traversal(node.left, result)
22
+ }
23
24
+ result.push(node.val)
25
26
+ if (node.right) {
27
+ traversal(node.right, result)
28
29
30
+ return result;
31
+}
Binary Tree Inorder Traversal/readme.md
@@ -0,0 +1 @@
+二叉树中序遍历递归解法
0 commit comments