id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

frew@mclean.com disco > inversePermutation
prev  |  next  |  chance

Given an array of size n of integers in range from 1 to n, we need to find the inverse permutation of that array. An inverse permutation is a permutation which you will get by inserting position of an element at the position specified by the element value in the array. Example : Input = {2, 3, 4, 5, 1} Output = {5, 1, 2, 3, 4} insert into position 2 the position of the 2 which is 1. Insert into position 3 the position of the 3 which is 2. Etc.


inversePermutation([1, 4, 3, 2]) → [1, 4, 3, 2]
inversePermutation([2, 3, 4, 5, 1]) → [5, 1, 2, 3, 4]
inversePermutation([3, 8, 5, 10, 9, 4, 6, 1, 7, 2]) → [8, 10, 1, 6, 3, 7, 9, 2, 5, 4]

...Save, Compile, Run (ctrl-enter)

public int[] inversePermutation(int[] nums) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200

Copyright Nick Parlante 2017 - privacy