SDE & MLE Prep

1929. Concatenation of Array

Problem

Return an array of length 2n that is nums followed by another copy of nums.

Example: [1,2,1] → [1,2,1,1,2,1]

Build nums + nums: allocate 2n slots and write each element twice, at i and i + n.

Complexity: O(n).

class Solution:
    def getConcatenation(self, nums: List[int]) -> List[int]:
        return nums + nums