565. Array Nesting

xiaoxiao2021-02-27  190

class Solution(object):     def arrayNesting(self, nums):         """         :type nums: List[int]         :rtype: int         """

        ans=0

step = 0

        seen = [False] * n         for i in range(len(nums)):             while not seen[i]:                 seen[i] = True                 i, step = nums[i], step + 1             ans = max(ans, step)             step = 0         return ans
转载请注明原文地址: https://www.6miu.com/read-11308.html

最新回复(0)