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 1st 2 lines of the problem statement should answer your question.
"You are given a sequence of n integers, p(1), p(2),...,p(n). Each element in the sequence is distinct and satisfies 1 <= p(x) <= n". So your original input is actually invalid input.
Also, I spent some hackos downloading several sample inputs, and the input was always within 1 to n.
Sequence Equation
You are viewing a single comment's thread. Return to all comments →
The 1st 2 lines of the problem statement should answer your question.
"You are given a sequence of n integers, p(1), p(2),...,p(n). Each element in the sequence is distinct and satisfies 1 <= p(x) <= n". So your original input is actually invalid input.
Also, I spent some hackos downloading several sample inputs, and the input was always within 1 to n.
HackerRank solutions.