Leetcode 1389. Create Target Array in the Given Order Posted on 2021-01-28 In LeetCode 題目123456789Input: nums = [0,1,2,3,4], index = [0,1,2,2,1]Output: [0,4,1,3,2]Explanation:nums index target0 0 [0]1 1 [0,1]2 2 [0,1,2]3 2 [0,1,3,2]4 1 [0,4,1,3,2] 解法思維運用splice(索引位置, 要刪除元素的數量, 元素) 1234567var createTargetArray =(nums, index)=> { let result=[] for (let i = 0; i < nums.length; i++) { result.splice(index[i],0,nums[i]) } return result};