Description
Given a 0-indexed integer array nums and a target value target, return a list of indices where target would be located after sorting the array in non-decreasing order.
Examples
Input:
nums = [1,2,5,2,3], target = 2Output:
[1,2]Explanation:
After sorting: [1,2,2,3,5], 2 at indices 1,2.
Input:
nums = [4,6,7,7,7,8], target = 7Output:
[2,3,4]Explanation:
After sorting: [4,6,7,7,7,8], target 7 appears at indices 2, 3, and 4. This demonstrates handling multiple consecutive occurrences of the target.
Input:
nums = [9,3,1,5], target = 10Output:
[]Explanation:
After sorting: [1,3,5,9], target 10 is not present in the array, so an empty array is returned.
Constraints
- •
1 ≤ nums.length ≤ 100