天天看點

LeetCode: Symmetric Tree [101]

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

For example, this binary tree is symmetric:

But the following is not:

Note:

Bonus points if you could solve it both recursively and iteratively.

confused what <code>"{1,#,2,3}"</code> means? 

    給定一棵二叉樹,判斷這個二叉樹是否自身左右對稱

    隻要判斷根節點的左右子樹是否對稱即可。用遞歸實作

    非遞歸實作(先序周遊實作)