@toby3d
class Solution {
public:
vector<int> targetIndices(vector<int>& nums, int target) {
vector<int> a;
int n = 0;
int l = 0;
for (auto i : nums) {
if (i < target) {
l++;
} else if (i == target) {
n++;
}
}
for (int i = 0; i < n; i++) {
a.push_back(l + i);
}
return a;
}
};
@atanu I use built-in "slices" and "sort" packages and saved on allocation by specifying capacity.
It is especially interesting that the solution using the construct `target < nums[i]` is 3ms slower but 0.04mb cheaper then `nums[i] != target`. I don't really understand why this is so.