2210. Find Target Indices After Sorting Array
My accepted C++ solution to LeetCode problem 2210, Find Target Indices After Sorting Array, running in 0ms.
- Difficulty: Easy
- C++
- Runtime 0ms
- Memory 15.1MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
C++
Accepted on LeetCode — runtime 0ms, memory 15.1MB, accepted 2025-12-27.
class Solution {
public:
vector<int> targetIndices(vector<int>& nums, int target) {
sort(nums.begin(), nums.end());
vector<int> result;
for (int i = 0; i < nums.size(); i++) {
if (nums[i] == target) result.push_back(i);
}
return result;
}
};