图片说明

/* function TreeNode(x) {
    this.val = x;
    this.left = null;
    this.right = null;
} */
function Mirror(root)
{
    // write code here
    if(!root) return null
    function buildImage(root){
        if(!root.left && !root.right) return
        var temp = root.left
        root.left = root.right
        root.right = temp
        if(root.left) buildImage(root.left)
        if(root.right) buildImage(root.right)
    }
    buildImage(root)
    return root
}