Search⌘ K
AI Features

Solution: Build Array from Permutation

Let's solve the Build Array from Permutation problem using the Math and Geometry pattern.

Statement

Given a zero-based permutation nums, construct an array ans of the same length where each element satisfies ans[i] = nums[nums[i]] for every valid index i, and return ans.

A zero-based permutation is an array of distinct integers ranging from 00 ...