Skip to main content
Back to problems
#1929
Easy Algorithms

Concatenation of array

Array Simulation
90.5% acceptance
Feb 25, 2026
4125
450
Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed). Specifically, ans is the concatenation of two nums arrays. Return the array ans.

Solution

Rust
Time O(1)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn get_concatenation(nums: Vec<i32>) -> Vec<i32> {
    [&nums[..], &nums[..]].concat()
  }
}