コード例 #1
0
        private static void Helper(LeetCode230TreeNode root)
        {
            if (root == null)
            {
                return;
            }

            Helper(root.left);
            list.Add(root.val);
            Helper(root.right);
        }
コード例 #2
0
        public static int KthSmallestElement(LeetCode230TreeNode root, int k)
        {
            Helper(root);

            return(list[k - 1]);
        }
コード例 #3
0
 public LeetCode230TreeNode(int val = 0, LeetCode230TreeNode left = null, LeetCode230TreeNode right = null)
 {
     this.val   = val;
     this.left  = left;
     this.right = right;
 }