di'tu
using System; using System.Collections.Generic; /* public class TreeNode { public int val; public TreeNode left; public TreeNode right; public TreeNode (int x) { val = x; } } */ class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param root TreeNode类 * @return int整型一维数组 */ public List<int> inorderTraversal (TreeNode root) { List<int> res = new List<int>(); if(root == null) return res; Inorder(root, res); return res; } public void Inorder(TreeNode root, List<int> res){ if(root == null) return; Inorder(root.left, res); res.Add(root.val); Inorder(root.right, res); return; } }