Beispiel #1
0
        private static LeetCode105TreeNode Helper(int left, int right)
        {
            if (left == right)
            {
                return(null);
            }

            var root_val = preOrder[pre_idx];

            var root  = new LeetCode105TreeNode(root_val);
            var index = idx_map[root_val];

            pre_idx++;

            root.left  = Helper(left, index);
            root.right = Helper(index + 1, right);
            return(root);
        }
Beispiel #2
0
 public LeetCode105TreeNode(int val = 0, LeetCode105TreeNode left = null, LeetCode105TreeNode right = null)
 {
     this.val   = val;
     this.left  = left;
     this.right = right;
 }