Concatenation of Array

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
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.
LeetCode Problem - 1929
class Solution {
// This method takes an array of integers as input and returns a new array that is the concatenation of the input array with itself.
public int[] getConcatenation(int[] nums) {
// Get the length of the input array.
int n = nums.length;
// Create a new array with double the length of the input array.
int[] ans = new int[2*n];
// Iterate through the input array.
for(int i=0; i<n; i++){
// Copy each element of the input array to the corresponding position in the new array.
ans[i] = nums[i];
// Copy each element of the input array to the second half of the new array.
ans[i+n] = nums[i];
}
// Return the concatenated array.
return ans;
}
}




