Elegant Solution - Java


#1
`public TreeNode solve(TreeNode A, TreeNode B) {
    if(A==null && B==null) return null;
    int valA = (A!=null) ? A.val : 0;
    int valB = (B!=null) ? B.val : 0;
    TreeNode node = new TreeNode(valA+valB);
    node.left = solve(A!=null ? A.left : null, B!=null ? B.left : null);
    node.right = solve(A!=null ? A.right : null, B!=null ? B.right : null);
    return node;
}`