LeetCode - Algorithms - 1389. Create Target Array in the Given Order

Weekly contest 181 easy problem.

Problem

1389. Create Target Array in the Given Order

Java

1
2
3
4
5
6
7
8
class Solution {
public int[] createTargetArray(int[] nums, int[] index) {
List<Integer> list = new ArrayList<Integer>();
for(int i=0;i<nums.length;i++)
list.add(index[i],nums[i]);
return list.stream().mapToInt(Integer::intValue).toArray();
}
}

Submission Detail

  • 44 / 44 test cases passed.