题目:
题解:
func arrayNesting(nums []int) (ans int) {
n := len(nums)
for i := range nums {
cnt := 0
for nums[i] < n {
i, nums[i] = nums[i], n
cnt++
}
if cnt > ans {
ans = cnt
}
}
return
}