Problem Statement of leetcode 1920:-
Given a zero-based permutation nums
(0-indexed), build an array ans
of the same length where ans[i] = nums[nums[i]]
for each 0 <= i < nums.length
and return it.
A zero-based permutation nums
is an array of distinct integers from 0
to nums.length - 1
(inclusive).
The problem is taken from :-
https://leetcode.com/problems/build-array-from-permutation/
Code:-
class Solution {
public int[] buildArray(int[] nums) {
int n = nums.length;
for (int i=0; i
The explanation of the problem is mentioned below:- https://industechie.com/index.php/2021/11/28/leetcode-1920-solution-in-java/
1 Reply to “java solution of Build Array from Permutation problem”
Comments are closed.