Solution: Find Target Indices After Sorting Array
Understand how to solve the problem of finding all indices of a target value in a sorted array by applying the sort and search pattern. This lesson guides you through sorting the array, locating target positions with a linear search, and returning a sorted list of these indices. You'll also learn the time and space complexity of this approach to better evaluate your solutions in coding interviews.
We'll cover the following...
Statement
You are given a 0-indexed array of positive integers, nums, and a value, target. The target represents an index 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:
nums.length...