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.
The explanation is correct and it is a good approach. However, the sequence (according to the hackerrank output) could not be generated, especially if one is coding in python. I don't know if others coding in different language or python is facing the same problem.
def permutationEquation(p):
l=[]
for i in range(1,len(p)+1):
l.append(p[p[i-1]-1])
return l
where p is the array of integers containing p(x).
Can anyone help this out?
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 →
The explanation is correct and it is a good approach. However, the sequence (according to the hackerrank output) could not be generated, especially if one is coding in python. I don't know if others coding in different language or python is facing the same problem. def permutationEquation(p): l=[] for i in range(1,len(p)+1): l.append(p[p[i-1]-1]) return l
where p is the array of integers containing p(x).
Can anyone help this out?