class Solution {
// brute force:
// step 1: take the new array of the same size of the given array
// step 2: itterate the loop on the given array
// step 3: apply the said statement and store the value of the perticular array
index
// step 4: at end of the loop return the new array
// time complexity: O(N);
// space complexity: O(N);
public int[] buildArray(int[] nums) {
// int[] ans= new int[[Link]];
// for(int i=0; i<[Link];i++){
// ans[i]=nums[nums[i]];
// }
// return ans;
// better solution:
// intuition: store the old and new number at the one place and then
extract the required value as per the convient
int n=[Link];
for(int i=0;i<n;i++){
nums[i]=nums[i]+n * (nums[nums[i]]%n);
}
for(int i=0;i<n;i++){
nums[i]/=n;
}
return nums;
}
}