MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / createTargetArray

Method createTargetArray

TargetArrayInGivenOrder.java:11–26  ·  view source on GitHub ↗
(int[] nums, int[] index)

Source from the content-addressed store, hash-verified

9 }
10 }
11 public int[] createTargetArray(int[] nums, int[] index) {
12 int target[] = new int[nums.length];
13 for(int i=0;i<nums.length;i++)
14 {
15 target[i]=-1;
16 }
17 for(int i=0;i<nums.length;i++)
18 {
19 if(target[index[i]]!=-1)
20 {
21 shift(target,index[i],target.length);
22 }
23 target[index[i]]=nums[i];
24 }
25 return target;
26 }
27}
28
29// Way two

Callers

nothing calls this directly

Calls 1

shiftMethod · 0.95

Tested by

no test coverage detected