Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1920. Build Array from Permutation
Given a zero-based permutation nums, return an array ans of the same length where ans[i] = nums[nums[i]] for every index i (i.e., compute the permutation composed with itself). The input guarantees distinct values 0..n-1 so indices are valid, and a follow-up asks for an in-place O(1) extra-space solution.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.