mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>表: <code>Employee</code></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
+-------------+------+
 | 
						|
| Column Name | Type |
 | 
						|
+-------------+------+
 | 
						|
| id          | int  |
 | 
						|
| salary      | int  |
 | 
						|
+-------------+------+
 | 
						|
id 是该表的主键(列中的值互不相同)。
 | 
						|
该表的每一行都包含有关员工工资的信息。
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
 | 
						|
<p>编写一个解决方案查询 <code>Employee</code> 表中第 <code>n</code> 高的 <strong>不同</strong> 工资。如果少于 <code>n</code> 个不同工资,查询结果应该为 <code>null</code> 。</p>
 | 
						|
 | 
						|
<p>查询结果格式如下所示。</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
 | 
						|
<p><strong>示例 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>输入:</strong> 
 | 
						|
Employee table:
 | 
						|
+----+--------+
 | 
						|
| id | salary |
 | 
						|
+----+--------+
 | 
						|
| 1  | 100    |
 | 
						|
| 2  | 200    |
 | 
						|
| 3  | 300    |
 | 
						|
+----+--------+
 | 
						|
n = 2
 | 
						|
<strong>输出:</strong> 
 | 
						|
+------------------------+
 | 
						|
| getNthHighestSalary(2) |
 | 
						|
+------------------------+
 | 
						|
| 200                    |
 | 
						|
+------------------------+
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>示例 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>输入:</strong> 
 | 
						|
Employee 表:
 | 
						|
+----+--------+
 | 
						|
| id | salary |
 | 
						|
+----+--------+
 | 
						|
| 1  | 100    |
 | 
						|
+----+--------+
 | 
						|
n = 2
 | 
						|
<strong>输出:</strong> 
 | 
						|
+------------------------+
 | 
						|
| getNthHighestSalary(2) |
 | 
						|
+------------------------+
 | 
						|
| null                   |
 | 
						|
+------------------------+</pre>
 |