Understand it like a graph  (python code)
For the example A[0] = 5, A[1] = 4, A[2] = 0, A[3] = 3, A[4] = 1, A[5] = 6, A[6] = 2.\nDraw a graph: \nThe problem can be transformed into a directed graph, and
For the example A[0] = 5, A[1] = 4, A[2] = 0, A[3] = 3, A[4] = 1, A[5] = 6, A[6] = 2.\nDraw a graph: ![image](https://assets.leetcode.com/users/islander/image_1539323348.png)\nThe problem can be transformed into a directed graph, and we are asked to get the size of largest connected component. So for example, from 0 we can explore the local connected component, and we don\'t need to check 5, 6, 2 again.\nI personally find this model to be easier to undertand, HIH\n\nIgnore my code below, this is better: https://leetcode.com/problems/array-nesting/discuss/102473/Python-solution\nCode: (we can use a count instead of a set, should be easy to change)\n```\nseen = set()\nresult = 0\nfor (i, num) in enumerate(nums):\n    if i not in seen:\n        cur_set = set([i])\n        seen.add(i)\n        j = num\n        while j not in cur_set:\n            cur_set.add(j)\n            seen.add(j)\n            j = nums[j]\n        result = max(result, len(cur_set))\nreturn result\n```
[]