赞
踩
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target) { // base case if (original == null) return null; if (original == target) return cloned; TreeNode l = getTargetCopy(original.left, cloned.left, target); TreeNode r = getTargetCopy(original.right, cloned.right, target); return l == null ? r : l; } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。