mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 03:33:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			973 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			973 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>Given the <code>root</code> of a binary tree, <em>check whether it is a mirror of itself</em> (i.e., symmetric around its center).</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong class="example">Example 1:</strong></p>
 | 
						|
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/symtree1.jpg" style="width: 354px; height: 291px;" />
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> root = [1,2,2,3,4,4,3]
 | 
						|
<strong>Output:</strong> true
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong class="example">Example 2:</strong></p>
 | 
						|
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/symtree2.jpg" style="width: 308px; height: 258px;" />
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> root = [1,2,2,null,3,null,3]
 | 
						|
<strong>Output:</strong> false
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li>The number of nodes in the tree is in the range <code>[1, 1000]</code>.</li>
 | 
						|
	<li><code>-100 <= Node.val <= 100</code></li>
 | 
						|
</ul>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<strong>Follow up:</strong> Could you solve it both recursively and iteratively? |