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 0155fc3 commit 72837e5Copy full SHA for 72837e5
leetcode_Java/Solution0094.java
@@ -0,0 +1,29 @@
1
+/**
2
+ * Definition for a binary tree node.
3
+ * public class TreeNode {
4
+ * int val;
5
+ * TreeNode left;
6
+ * TreeNode right;
7
+ * TreeNode() {}
8
+ * TreeNode(int val) { this.val = val; }
9
+ * TreeNode(int val, TreeNode left, TreeNode right) {
10
+ * this.val = val;
11
+ * this.left = left;
12
+ * this.right = right;
13
+ * }
14
15
+ */
16
+
17
+// 二叉树的中序遍历
18
+class Solution0094 {
19
+ List<Integer> list = new ArrayList<>();
20
21
+ public List<Integer> inorderTraversal(TreeNode root) {
22
+ if (root != null) {
23
+ inorderTraversal(root.left);
24
+ list.add(root.val);
25
+ inorderTraversal(root.right);
26
+ }
27
+ return list;
28
29
+}
0 commit comments