Monday, January 7, 2013 [LeetCode] Symmetric Tree 解题报告 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following is not: 1 / \ 2 2 \ \ 3 3 Note: Bonus points if you could solve it both recursively and iteratively. confused what "{1,#,2,3}" 左节点的左子树和右节点的右子树对称 左节点的右子树和右节点的左子树对称 [Code] 非递归解法 1: bool isSymmetric(TreeNode *root) { 2: if(root == NULL) return true; 3: vector
Read full article from 水中的鱼: [LeetCode] Symmetric Tree 解题报告
No comments:
Post a Comment