Description
Submission
class Solution { public: vector<int> createTargetArray(vector<int>& nums, vector<int>& index) { list<int> l; int n = nums.size(); for(int i = 0; i < n; ++i) { auto it = l.begin(); for(int j = 0; j < index[i]; ++j, ++it); l.insert(it, nums[i]); } return {l.begin(), l.end()}; } };