1 January 2015

Quiz 74: Rearranging elements of list

Problem:

Input is a list containing N numbers from 1 to N in random order.Rearrange the list in such a way that "position of ith element is the value of ith element of list.ie for 4 1 2 3:new position of 4 should be value of 4th element ie 3rdnew position of 1 should be value of 1st element ie 4thnew position of 2 should be value of 2nd element ie 1st.new position of 3 should be value of 3rd element ie 2nd.So new arrangement would be 2 3 4 1