Single Cycle Search Time : O(n) Space : O(1) 1234567891011bool hasSingleCycle(vector<int> array) { int n = array.size(); int vis = 0, idx = 0; while(vis < n) { if(vis > 0 and idx == 0) return false; vis++; idx = ((array[idx] % n) + n + idx) % n; } return idx == 0;}