leetcode565】的更多相关文章

A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below. Suppose the first element in S starts with the selection…
public class Solution { public int ArrayNesting(int[] nums) { ; ; i < nums.Length; i++) { ; ; size++) { int ak = nums[k]; nums[k] = -; // mark a[k] as visited; k = ak; } maxsize = Math.Max(maxsize, size); } return maxsize; } } https://leetcode.com/pr…