python what's worng with the solution its working for [0,1,2] not for [0,2,1]
\nclass Solution:\n    def arrayNesting(self, nums: List[int]) -> int:\n        s=[]\n        i=0\n        while i!=None:\n            i=nums[i]\n            if
```\nclass Solution:\n    def arrayNesting(self, nums: List[int]) -> int:\n        s=[]\n        i=0\n        while i!=None:\n            i=nums[i]\n            if i not in s:\n                s.append(i)\n            else:\n                break\n        return len(set(s))\n```
[]