leetcode——101. 对称二叉树
Posted 欣姐姐
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode——101. 对称二叉树相关的知识,希望对你有一定的参考价值。
class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not root:return True def Tree(p,q): if not p and not q:return True if p and q and p.val==q.val: return Tree(p.left,q.right) and Tree(p.right,q.left) return False return Tree(root.left,root.right)
执行用时 :24 ms, 在所有 python 提交中击败了76.38%的用户
内存消耗 :12 MB, 在所有 python 提交中击败了14.26%的用户
——2019.11.10
以上是关于leetcode——101. 对称二叉树的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode 101.对称二叉树 - JavaScript
⭐算法入门⭐《二叉树》简单03 —— LeetCode 101. 对称二叉树