java.lang.Object
g2001_2100.s2089_find_target_indices_after_sorting_array.Solution

public class Solution extends Object
2089 - Find Target Indices After Sorting Array.<p>Easy</p> <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><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [1,2,5,2,3], target = 2</p> <p><strong>Output:</strong> [1,2]</p> <p><strong>Explanation:</strong> After sorting, nums is [1, <strong>2</strong> , <strong>2</strong> ,3,5].</p> <p>The indices where nums[i] == 2 are 1 and 2.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [1,2,5,2,3], target = 3</p> <p><strong>Output:</strong> [3]</p> <p><strong>Explanation:</strong> After sorting, nums is [1,2,2, <strong>3</strong> ,5].</p> <p>The index where nums[i] == 3 is 3.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> nums = [1,2,5,2,3], target = 5</p> <p><strong>Output:</strong> [4]</p> <p><strong>Explanation:</strong> After sorting, nums is [1,2,2,3, <strong>5</strong> ].</p> <p>The index where nums[i] == 5 is 4.</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>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • targetIndices

      public List<Integer> targetIndices(int[] nums, int target)