mirror of
				https://gitee.com/coder-xiaomo/leetcode-problemset
				synced 2025-11-04 11:43:12 +08:00 
			
		
		
		
	国外版
This commit is contained in:
		
							
								
								
									
										41
									
								
								算法题(国外版)/find-target-indices-after-sorting-array.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								算法题(国外版)/find-target-indices-after-sorting-array.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> and a target element <code>target</code>.</p>
 | 
			
		||||
 | 
			
		||||
<p>A <strong>target index</strong> is an index <code>i</code> such that <code>nums[i] == target</code>.</p>
 | 
			
		||||
 | 
			
		||||
<p>Return <em>a list of the target indices of</em> <code>nums</code> after<em> sorting </em><code>nums</code><em> in <strong>non-decreasing</strong> order</em>. If there are no target indices, return <em>an <strong>empty</strong> list</em>. The returned list must be sorted in <strong>increasing</strong> order.</p>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Example 1:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [1,2,5,2,3], target = 2
 | 
			
		||||
<strong>Output:</strong> [1,2]
 | 
			
		||||
<strong>Explanation:</strong> After sorting, nums is [1,<u><strong>2</strong></u>,<u><strong>2</strong></u>,3,5].
 | 
			
		||||
The indices where nums[i] == 2 are 1 and 2.
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 2:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [1,2,5,2,3], target = 3
 | 
			
		||||
<strong>Output:</strong> [3]
 | 
			
		||||
<strong>Explanation:</strong> After sorting, nums is [1,2,2,<u><strong>3</strong></u>,5].
 | 
			
		||||
The index where nums[i] == 3 is 3.
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p><strong>Example 3:</strong></p>
 | 
			
		||||
 | 
			
		||||
<pre>
 | 
			
		||||
<strong>Input:</strong> nums = [1,2,5,2,3], target = 5
 | 
			
		||||
<strong>Output:</strong> [4]
 | 
			
		||||
<strong>Explanation:</strong> After sorting, nums is [1,2,2,3,<u><strong>5</strong></u>].
 | 
			
		||||
The index where nums[i] == 5 is 4.
 | 
			
		||||
</pre>
 | 
			
		||||
 | 
			
		||||
<p> </p>
 | 
			
		||||
<p><strong>Constraints:</strong></p>
 | 
			
		||||
 | 
			
		||||
<ul>
 | 
			
		||||
	<li><code>1 <= nums.length <= 100</code></li>
 | 
			
		||||
	<li><code>1 <= nums[i], target <= 100</code></li>
 | 
			
		||||
</ul>
 | 
			
		||||
		Reference in New Issue
	
	Block a user