Arm Cortex处理器JTAG IDCODE解析与调试指南
2026/5/28 21:31:17
1、解法1:root的左右子树作为输入进行递归
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def isSymmetric(self, root: Optional[TreeNode]) -> bool: # 判断轴对称 if not root: return True # root的左右子树同时递归: def recur(leftNode,rightNode): if not leftNode and not rightNode: return True if not leftNode or not rightNode or leftNode.val != rightNode.val: return False return recur(leftNode.right,rightNode.left) and recur(leftNode.left,rightNode.right) return recur(root.left,root.right)