π One-stop destination for all your technical interview Preparation π
Given two arrays of integers nums and index. Your task is to create target array under the following rules:
It is guaranteed that the insertion operations will be valid.
class Solution{
public:
vector<int> createTargetArray(vector<int> &nums, vector<int> &index)
{
vector<int> ans;
int n = nums.size();
for (int i = 0; i < n; i++)
ans.insert(ans.begin() + index[i], nums[i]);
return ans;
}
};