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 2188843 commit ca18132Copy full SHA for ca18132
94.二叉树的中序遍历.js
@@ -0,0 +1,26 @@
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
+var inorderTraversal = function(root) {
13
+ const result = [];
14
+ const stack = [];
15
+ let cur = root;
16
+ while (cur !== null || stack.length !== 0) {
17
+ while (cur !== null) {
18
+ stack.push(cur);
19
+ cur = cur.left;
20
+ }
21
+ cur = stack.pop();
22
+ result.push(cur.val);
23
+ cur = cur.right;
24
25
+ return result;
26
+};
0 commit comments