This is my CPP solution.
class Solution {
public:
vector<int> createTargetArray(vector<int>& nums, vector<int>& index) {
int n = nums.size();
vector<int>target;
target.push_back(nums[0]);
for(int i=1;i<n;i++){
target.insert(target.begin()+index[i],nums[i]);
}
return target;
}
};