LeetCode solutions

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

Read the problem on LeetCode View on GitHub

C++

Accepted on LeetCode — runtime 0ms, memory 15.1MB, accepted 2025-12-27.

cpp
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;
    }
};

Source