1389. Create Target Array in the Given Order

Information

  • Diffculty: Easy

  • Created: 2020-03-22 15:06:00

  • Last Motified: 2020-03-22 15:06:54

  • Tags: Array

Intuition

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

Solution

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