personal question

You have an integer array. Starting from arr[startIndex], follow each element to the index it points to. You continue to do this until you find a cycle. Return the length of the cycle. If no cycle is found return -1
forexample {1, 0}, 0) => 2
{1, 2, 0}, 0) => 3
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.