✅Java Simple Solution || ✅Runtime 94.17% || ✅ Memory 99.57%
Intuition\nThe code aims to concatenate the given array nums with itself, forming a new array of length \'2*len\', where len is the length of the input array. I
# Intuition\nThe code aims to concatenate the given array nums with itself, forming a new array of length **\'2*len\'**, where len is the length of the input array. In other words, the code duplicates each element in nums and appends it to the end of the array.\n\n# Approach\n1. Create a new integer array \'**ans**\' of size \'**2*len**\', where \'**len**\' is the length of the input array \'**nums**\'.\n2. Iterate over the elements of \'**nums**\' using a for loop.\n3. For each element at index \'i\', assign \'**nums[i]**\' to \'**ans[i]**\' (copy the element).\n4. Assign \'**nums[i]**\' to \'**ans[i+len]**\' (append the element to the end of the array).\n5. Return the resulting array **\'ans\'**.\n\n# Complexity\n- Time complexity:\n\nThe code has a time complexity of **O(n)**, where n is the length of the input array nums. The loop iterates over each element in nums exactly once.\n\n- Space complexity:\n\nThe code has a space complexity of **O(n)**, where n is the length of the input array nums. The additional space is used to store the resulting array ans, which has a size of 2*len.\n\n# Code\n```\nclass Solution {\n    public int[] getConcatenation(int[] nums) {\n        int len = nums.length;\n        int[] ans = new int[2*len];\n        for(int i = 0; i < len; i++){\n            ans[i] = nums[i];\n            ans[i+len] = nums[i];\n        }\n        return ans;\n    }\n}\n```\n![image.png](https://assets.leetcode.com/users/images/a77a67df-1d24-4a28-8b5a-9c11222c830d_1686204633.8794553.png)\n\n
['Java']