#101

Symmetric Tree

pupil · 365 · lc easy +23 · verified · 60.8% accepted · 16,771 likes · top 60%

play →

Description

Determine whether the binary tree rooted at root is symmetric — that is, whether it looks the same when reflected across its vertical center axis.

Example 1:

Input: root = [1,2,2,3,4,4,3]
Output: true

Example 2:

Input: root = [1,2,2,null,3,null,3]
Output: false

Code

1
2
3
4
5
6
7
8
9