Create Target Array in the Given Order

Problem Id: 1389 Difficulty: Easy Tag: Array


The maximum length of the array is 100, so we could simply solve this problem using brute force.


class Solution:
    def createTargetArray(self, nums: List[int], index: List[int]) -> List[int]:
        target = []
        for num, i in zip(nums, index):
            target = target[:i] + [num] + target[i:]
        return target