Find the value an array sequence P[k+1] = P[P[k]] settles into, or return -1.
Unlock detailed company stats for this questionUpgrade
Given an array where P[2] = P[P[1]], P[3] = P[P[2]] and so on, determine the resulting value once the sequence forms a cycle, or return -1 if it does not resolve.
Community answers
No answers contributed by the community yet.
Related questions
Find the kth largest value in an array.Find the maximum even subsequence in an array.Find the k-th largest element in an array and return its index.Related courses

Course

Course
Course
