56. Find Target Indices After Sorting Array

EasyArrayArray

You are given a 0-indexed integer array nums and a target integer target. Return a list of target indices of target after sorting nums in non-decreasing order. If no target exists, return an empty list.

Input: An integer array nums and an integer target.

Output: Sorted list of indices where target appears in the sorted array.

Examples

Example 1
Input: [1,2,5,2,3],2
Output: [1,2]
Explanation: Sorted: [1,2,2,3,5]. Target 2 at indices 1,2.
Example 2
Input: [1,2,5,2,3],3
Output: [3]
Explanation: Sorted: [1,2,2,3,5]. Target 3 at index 3.
Example 3
Input: [1,2,5,2,3],4
Output: []
Explanation: 4 not in sorted array. Return [].

Constraints

Asked by

GoogleAmazonMeta
Solve this problem in the editor →