← Goldman Sachs questions

Find length of cycle in array

Filed under Goldman Sachs

Given an integer array of size N where elements are >= 0, start from arr[startIndex] and follow each element to the index it points to until a cycle is found. Return the length of the cycle, or -1 if…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Goldman Sachs questions

Collected from public candidate posts and coding forums. Updated Nov 2026.