You are viewing a single comment's thread. Return to all comments →
Kotlin:
fun permutationEquation(p: Array<Int>): Array<Int> { val size=p.size val indexArray=IntArray(size) { 0 } val result=Array(size) { 0 } for(i in 0 until size){ indexArray[i]= p.indexOf(i+1)+1 } for(i in 0 until size){ result[i]=p.indexOf(indexArray[i])+1 } return result }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Sequence Equation
You are viewing a single comment's thread. Return to all comments →
Kotlin: