Loading
Leetcode / 1929. Concatenation of Array

Pick a programming language:

Here is the source code for the solution to this problem.

class Solution {
    public int[] getConcatenation(int[] nums) {
        int[] ans = new int[nums.length * 2];

        for (int i = 0; i < nums.length; i++) {
            ans[i] = nums[i];
            ans[i + nums.length] = nums[i];
        }

        return ans;
    }
}
Did you like the lesson? 😆👍
Consider a donation to support our work: