import java.util.*;
/*
* public class TreeNode {
* int val = 0;
* TreeNode left = null;
* TreeNode right = null;
* public TreeNode(int val) {
* this.val = val;
* }
* }
*/
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param root TreeNode类
* @return int整型一维数组
*/
int len=0;
int result[];
int len1=0;
public int[] inorderTraversal (TreeNode root) {
// write code here
if(root==null){
result=new int[0];
return result;
}
get(root);
result=new int[len];
set(root);
return result;
}
public void get(TreeNode tree){
if(tree.left!=null){
get(tree.left);
}
len++;
if(tree.right!=null){
get(tree.right);
}
}
public void set(TreeNode root){
if(root.left!=null){
set(root.left);
}
result[len1]=root.val;
len1++;
if(root.right!=null){
set(root.right);
}
}
}
/*
* public class TreeNode {
* int val = 0;
* TreeNode left = null;
* TreeNode right = null;
* public TreeNode(int val) {
* this.val = val;
* }
* }
*/
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param root TreeNode类
* @return int整型一维数组
*/
int len=0;
int result[];
int len1=0;
public int[] inorderTraversal (TreeNode root) {
// write code here
if(root==null){
result=new int[0];
return result;
}
get(root);
result=new int[len];
set(root);
return result;
}
public void get(TreeNode tree){
if(tree.left!=null){
get(tree.left);
}
len++;
if(tree.right!=null){
get(tree.right);
}
}
public void set(TreeNode root){
if(root.left!=null){
set(root.left);
}
result[len1]=root.val;
len1++;
if(root.right!=null){
set(root.right);
}
}
}