mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										26
									
								
								算法题(国外版)/univalued-binary-tree.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								算法题(国外版)/univalued-binary-tree.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
<p>A binary tree is <strong>uni-valued</strong> if every node in the tree has the same value.</p>
 | 
			
		||||
 | 
			
		||||
<p>Given the <code>root</code> of a binary tree, return <code>true</code><em> if the given tree is <strong>uni-valued</strong>, or </em><code>false</code><em> otherwise.</em></p>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
<img alt="" src="https://assets.leetcode.com/uploads/2018/12/28/unival_bst_1.png" style="width: 265px; height: 172px;" />
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> root = [1,1,1,1,1,null,1]
 | 
			
		||||
<strong>Output:</strong> true
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
<img alt="" src="https://assets.leetcode.com/uploads/2018/12/28/unival_bst_2.png" style="width: 198px; height: 169px;" />
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> root = [2,2,2,5,2]
 | 
			
		||||
<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, 100]</code>.</li>
 | 
			
		||||
	<li><code>0 <= Node.val < 100</code></li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user