HPV121
BAN USER
Comments (2)
Followers (4)
Reputation 40
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
RepYaritzaLewis, abc at 8x8
I am working as a receptionist in a Softage company. I work with the HR department to facilitate recruitment drives ...
Repcloptonchirsty, Android Engineer at 8x8
Hello, I am an Organic chemist and my all study and degree is complete from New York.Apart from this ...
Repneilsjohn4563, Android Engineer at ABC TECH SUPPORT
Hello, I am a multimedia artist. I have 4 years experience in this.A multimedia Artist is someone who is ...
RepJulianMiller, abc at ABC TECH SUPPORT
I am a professional auditing assistant with extensive experience in handling administrative duties and executive responsibilities associated with both internal ...
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
This is my solution using ArrayList. Suggestions are welcomed.
I am adding every visited index in the arrayList and checking that whether it's been previously added or not. If it is already in the arrayList then there exist a cycle otherwise no cycle.
Even if the array is like [2,0,0,0,0]. There is a cycle after first iteration. Because after reaching at index 2 from the start, in the next iteration I am again visiting it because of the 0 displacement.
If the above situation is not to be taken care of then we can add one more condition to check whether the new value is the same as previous(previous = value at the end of the for loop) value then need to break the loop and return false.
- HPV121 December 02, 2016