Sobes.tech
Junior — Senior

Array element duplication

livecode

Task condition

Given an array of integers values of length n. Write a program that forms an array result of length 2 n such that result[i] == values[i] and result[i + n] == values[i] for all 0 ≤ i < n. The function should return the resulting array result.

Example 1: Input: values = [1,2,1] Output: [1,2,1,1,2,1]

Example 2: Input: values = [1,3,2,1] Output: [1,3,2,1,1,3,2,1]