Tip 1 : Do some projects
Tip 2 : Be good in data structure
Tip 1 : Keep it short
Tip 2 : Don't try to add false things.
The idea is to do a depth-first search to find all the cycles which are formed and calculate the length of the largest cycle. We are treating the array as a graph of directed edges. Whenever we get into any of the cells in the cycle, using dfs we will visit all the subsequent cells in the cycle. Out of all the cycles, we will return the cycle of maximum length.
The steps are as follows:<...