Search⌘ K
AI Features

Solution: Find Target Indices After Sorting Array

Explore how to find target value indices in a sorted array by first organizing data with sorting, then searching for matching elements. Understand this combines sorting and linear search for an efficient solution with O(n log n) time complexity and constant extra space. This lesson helps you master the Sort and Search pattern to solve similar array problems confidently.

Statement

You are given a 0-indexed array of positive integers, nums, and a value, target. The target represents an index ii in the array such that nums[i] == target.

Your task is to return a list of indexes of nums where the value equals target after sorting the array in nondecreasing order. If no such indexes exist, return an empty list. Ensure the returned list is sorted in increasing order.

Constraints:

  • 11 \leq nums.length 100\leq 100 ...