Solution in Python 3 (beats 100%) (only seven lines)
```\nclass Solution:\n    def arrayNesting(self, n: List[int]) -> int:\n    \tS = {}\n    \tfor i in range(len(n)):\n    \t\tif n[i] == -1: continue\n    \t\tm,
```\nclass Solution:\n    def arrayNesting(self, n: List[int]) -> int:\n    \tS = {}\n    \tfor i in range(len(n)):\n    \t\tif n[i] == -1: continue\n    \t\tm, a = 0, i\n    \t\twhile n[a] != -1: n[a], a, b, m = -1, n[a], a, m + 1\n    \t\tS[i] = m + S.pop(b, 0)\n    \treturn max(S.values())\n\n\n- Python 3\n(LeetCode ID)@hotmail.com
['Python', 'Python3']