검지offer-js 두 갈래 나무의 거울
2075 단어 검지offer
두 갈래 나무의 거울
제목 설명:
, 。
:
:
8
/ \
6 10
/ \ / \
5 7 9 11
8
/ \
10 6
/ \ / \
11 9 7 5
문제 분석:
,
코드 표시:
/* function TreeNode(x) {
this.val = x;
this.left = null;
this.right = null;
} */
function Mirror(root)
{
// ,
if(root === null)
return;
let tmp = root.left; //
root.left = root.right;
root.right = tmp;
Mirror(root.left); //
Mirror(root.right); //
}