We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
It's nearly impossible to write a readable solution to such a nonsensical problem. It's bascially asking you to think in terms of POSITION instead of 0 based index. The solution to that problem is a 1 based index, hence the + 1's you see.
Java 8 Solution:
publicstaticList<Integer>permutationEquation(List<Integer>intArray){// Write your code hereList<Integer>returnList=newArrayList<Integer>();for(inti=1;i<=intArray.size();i++){intoutterPos=intArray.indexOf(i)+1;returnList.add(intArray.indexOf(outterPos)+1);}returnreturnList;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sequence Equation
You are viewing a single comment's thread. Return to all comments →
It's nearly impossible to write a readable solution to such a nonsensical problem. It's bascially asking you to think in terms of POSITION instead of 0 based index. The solution to that problem is a 1 based index, hence the + 1's you see.
Java 8 Solution: