Create Target Array in the Given Order

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 two arrays of integers nums and index. Your task is to create target array under the following rules:
Initially target array is empty.
From left to right read nums[i] and index[i], insert at index
index[i]the valuenums[i]in target array.Repeat the previous step until there are no elements to read in
numsandindex.
Return the target array.
It is guaranteed that the insertion operations will be valid.
LeetCode Problem - 1389
class Solution {
// Method to create a target array based on given values and indices
public int[] createTargetArray(int[] nums, int[] index) {
// ArrayList to store the target array
ArrayList<Integer> arr = new ArrayList<>();
// Iterate through each element in nums and insert it at the specified index in arr
for (int i=0; i<nums.length; i++){
arr.add(index[i], nums[i]);
}
// Convert the ArrayList to an array
int[] ans = new int[nums.length];
for (int i=0; i<arr.size(); i++){
ans[i] = arr.get(i);
}
// Return the final target array
return ans;
}
}




