mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>给你一个整数数组 <code>nums</code> ,返回出现最频繁的偶数元素。</p>
 | 
						||
 | 
						||
<p>如果存在多个满足条件的元素,只需要返回 <strong>最小</strong> 的一个。如果不存在这样的元素,返回 <code>-1</code> 。</p>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>示例 1:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>nums = [0,1,2,2,4,4,1]
 | 
						||
<strong>输出:</strong>2
 | 
						||
<strong>解释:</strong>
 | 
						||
数组中的偶数元素为 0、2 和 4 ,在这些元素中,2 和 4 出现次数最多。
 | 
						||
返回最小的那个,即返回 2 。</pre>
 | 
						||
 | 
						||
<p><strong>示例 2:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>nums = [4,4,4,9,2,4]
 | 
						||
<strong>输出:</strong>4
 | 
						||
<strong>解释:</strong>4 是出现最频繁的偶数元素。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p><strong>示例 3:</strong></p>
 | 
						||
 | 
						||
<pre><strong>输入:</strong>nums = [29,47,21,41,13,37,25,7]
 | 
						||
<strong>输出:</strong>-1
 | 
						||
<strong>解释:</strong>不存在偶数元素。
 | 
						||
</pre>
 | 
						||
 | 
						||
<p> </p>
 | 
						||
 | 
						||
<p><strong>提示:</strong></p>
 | 
						||
 | 
						||
<ul>
 | 
						||
	<li><code>1 <= nums.length <= 2000</code></li>
 | 
						||
	<li><code>0 <= nums[i] <= 10<sup>5</sup></code></li>
 | 
						||
</ul>
 |