EasyRating 1200
101. Symmetric Tree
treedepth-first-searchbreadth-first-searchbinary-tree
解題說明
C++ 解法
複雜度分析
虛擬碼
1. If root is null, return true (empty tree is symmetric). 2. Call isMirror(root.left, root.right). 3. In isMirror(left, right): a. If both left and right are null, return true. b. If exactly one of them is null, return false. c. If left.val != right.val, return false. d. Return isMirror(left.left, right.right) AND isMirror(left.right, right.left).