Given a zero-based permutation nums, construct an array ans of the same length such that, ans[i] = nums[nums[i]] for every valid index i.
Return the constructed array ans.
A zero-based permutation is an array of distinct integers from
0tonums.length - 1, inclusive.
Constraints:
nums.length
nums[i] nums.length
All elements in nums are distinct.
Given a zero-based permutation nums, construct an array ans of the same length such that, ans[i] = nums[nums[i]] for every valid index i.
Return the constructed array ans.
A zero-based permutation is an array of distinct integers from
0tonums.length - 1, inclusive.
Constraints:
nums.length
nums[i] nums.length
All elements in nums are distinct.