You are given an integer array nums of length nums is a permutation of the numbers in the range
You should build a set s[k] = \\{ nums[k], nums[nums[k]], nums[nums[nums[k]]], \dots \\} subjected to the following rule:
The first element in nums[k] of index
The next element in nums[nums[k]], and then nums[nums[nums[k]]], and so on.
We stop adding right before a duplicate element occurs in
Return the longest length of a set
Constraints:
nums.length
nums[i] nums.length
All the values of nums are unique.
You are given an integer array nums of length nums is a permutation of the numbers in the range
You should build a set s[k] = \\{ nums[k], nums[nums[k]], nums[nums[nums[k]]], \dots \\} subjected to the following rule:
The first element in nums[k] of index
The next element in nums[nums[k]], and then nums[nums[nums[k]]], and so on.
We stop adding right before a duplicate element occurs in
Return the longest length of a set
Constraints:
nums.length
nums[i] nums.length
All the values of nums are unique.