題解 | #二叉樹的鏡像#
二叉樹的鏡像
http://fangfengwang8.cn/practice/a9d0ecbacef9410ca97463e4a5c83be7
/* * function TreeNode(x) { * this.val = x; * this.left = null; * this.right = null; * } */ /** * 代碼中的類名、方法名、參數(shù)名已經(jīng)指定,請(qǐng)勿修改,直接返回方法規(guī)定的值即可 * * * @param pRoot TreeNode類 * @return TreeNode類 */ function Mirror( pRoot ) { // write code here if (pRoot) { let tem = pRoot.left pRoot.left = pRoot.right pRoot.right = tem Mirror(pRoot.left) Mirror(pRoot.right) } return pRoot } module.exports = { Mirror : Mirror };