':type nums: List[int]
:rtype: int'

def arrayNesting(self, nums):

    result = 0
    for num in nums:
        if (num != None):
            (start, count) = (num, 0)
            while (nums[start] != None):
                temp = start
                start = nums[start]
                nums[temp] = None
                count += 1
            result = max(result, count)
    return result
