mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 19:53:12 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<p>You are given an array of strings <code>names</code>, and an array <code>heights</code> that consists of <strong>distinct</strong> positive integers. Both arrays are of length <code>n</code>.</p>
 | 
						|
 | 
						|
<p>For each index <code>i</code>, <code>names[i]</code> and <code>heights[i]</code> denote the name and height of the <code>i<sup>th</sup></code> person.</p>
 | 
						|
 | 
						|
<p>Return <code>names</code><em> sorted in <strong>descending</strong> order by the people's heights</em>.</p>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Example 1:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> names = ["Mary","John","Emma"], heights = [180,165,170]
 | 
						|
<strong>Output:</strong> ["Mary","Emma","John"]
 | 
						|
<strong>Explanation:</strong> Mary is the tallest, followed by Emma and John.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p><strong>Example 2:</strong></p>
 | 
						|
 | 
						|
<pre>
 | 
						|
<strong>Input:</strong> names = ["Alice","Bob","Bob"], heights = [155,185,150]
 | 
						|
<strong>Output:</strong> ["Bob","Alice","Bob"]
 | 
						|
<strong>Explanation:</strong> The first Bob is the tallest, followed by Alice and the second Bob.
 | 
						|
</pre>
 | 
						|
 | 
						|
<p> </p>
 | 
						|
<p><strong>Constraints:</strong></p>
 | 
						|
 | 
						|
<ul>
 | 
						|
	<li><code>n == names.length == heights.length</code></li>
 | 
						|
	<li><code>1 <= n <= 10<sup>3</sup></code></li>
 | 
						|
	<li><code>1 <= names[i].length <= 20</code></li>
 | 
						|
	<li><code>1 <= heights[i] <= 10<sup>5</sup></code></li>
 | 
						|
	<li><code>names[i]</code> consists of lower and upper case English letters.</li>
 | 
						|
	<li>All the values of <code>heights</code> are distinct.</li>
 | 
						|
</ul>
 |