File tree 1 file changed +45
-0
lines changed
LeetcodeProblems/Algorithm
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ source:
2
+ - https ://leetcode.com/problems/binary-tree-inorder-traversal/
3
+ level:
4
+ - medium
5
+ description:
6
+ - Given a binary tree , return the inorder traversal of its nodes ' values.
7
+ tags :
8
+ - Hash Table
9
+ - Stack
10
+ - Tree
11
+ solutions:
12
+ -
13
+ - runtime : ms , beats %
14
+ - memory : MB , beats %
15
+ -- -
16
+ * /
17
+
18
+ /**
19
+ * Definition for a binary tree node.
20
+ * function TreeNode(val) {
21
+ * this.val = val;
22
+ * this.left = this.right = null;
23
+ * }
24
+ */
25
+ /**
26
+ * @param {TreeNode } root
27
+ * @return {number[] }
28
+ */
29
+ var inorderTraversalInterativeWithHelper = function ( root ) {
30
+ const result = [ ] ;
31
+ helper ( root , result )
32
+ return result
33
+ } ;
34
+
35
+ const helper = ( root , result ) => {
36
+ if ( root ) {
37
+ helper ( root . left , result )
38
+ result . push ( root . val )
39
+ helper ( root . right , result )
40
+ }
41
+ }
42
+
43
+ module . exports = {
44
+ inorderTraversalInterativeWithHelper
45
+ } ;
You can’t perform that action at this time.
0 commit comments