递归
function Mirror( pRoot ) {
if(pRoot == null)
return;
let tmp = pRoot.left;
pRoot.left = pRoot.right;
pRoot.right = tmp;
Mirror(pRoot.left);
Mirror(pRoot.right);
return pRoot;
}
module.exports = {
Mirror : Mirror
};
递归
function Mirror( pRoot ) {
if(pRoot == null)
return;
let tmp = pRoot.left;
pRoot.left = pRoot.right;
pRoot.right = tmp;
Mirror(pRoot.left);
Mirror(pRoot.right);
return pRoot;
}
module.exports = {
Mirror : Mirror
};