Given a zero-based permutation nums, build ans where ans[i] = nums[nums[i]].
result of the same length.i, set ans[i] to the element located at index nums[i] in nums.result.class Solution {
public int[] buildArray(int[] nums) {
int n = nums.length;
int[] result = new int[n];
for (int i = 0; i < n; i++) {
result[i] = nums[nums[i]];
}
return result;
}
}