Sequence Equation

Problem statement-
Below is problem statement for the hackerrank problem.

Solution:-
A tricky hackerrank problem, where we are give a list say p=[5,2,1,3,4] and the length of list is 5 so x value will be from 1 to 5.

Lets move towards the code, first we will declare an empty list say ‘b’ then we will iterate it till length of the list p. First we will find index of ith i.e. in first iteration i=1 so we will find the index of 1 in list “p” and add 1 to it and store the value in j. Again we will calculate the index of value in j and add 1 to it and store it in x and append each such values in a list name “b”

Conclusion-Keep learning and keep hustling….(cheers:-PN)