public class Solution {
public int ArrayNesting(int[] nums) {
int maxsize = ;
for (int i = ; i < nums.Length; i++)
{
int size = ;
for (int k = i; nums[k] >= ; size++)
{
int ak = nums[k];
nums[k] = -; // mark a[k] as visited;
k = ak;
}
maxsize = Math.Max(maxsize, size);
} return maxsize;
}
}

https://leetcode.com/problems/array-nesting/#/description

leetcode565的更多相关文章

  1. [Swift]LeetCode565. 数组嵌套 | Array Nesting

    A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest ...

随机推荐

  1. opencv:创建滑动条

    函数原型: ,); #include <opencv.hpp> using namespace cv; #define WINDOW_NAME "线性混合示例" // ...

  2. Week03-Java学习笔记第三次作业

    Week03-面向对象入门 1.本周学习总结 初学面向对象,会学习到很多碎片化的概念与知识.尝试学会使用思维导图将这些碎片化的概念.知识点组织起来.请使用工具画出本周学习到的知识点及知识点之间的联系. ...

  3. iis不能访问html

    在iis中配置好虚拟目录后,打开目录下的一个html文件,发现不是按照预想的输出,查看源代码后发现代码是: <html><head></head><body& ...

  4. java中常用的帮助类。加快开发速度

    数据库帮助类 package com.cwnu.uitl; import java.sql.*; /** * 数据库基础操作实现类 * * @author BlackWinter * * @date ...

  5. Qt之图形(QPainterPath)

    简述 QPainterPath 类(绘图路径)提供了一个容器,用于绘图操作,可以创建和重用图形形状. 绘图路径是由许多图形化的构建块组成的对象,例如:矩形.椭圆.直线和曲线.构建块可以加入在封闭的子路 ...

  6. Asphyre Sphinx is a cross-platform framework for developing 2D/3D video games and interactive business applications

    Introduction Introduction Asphyre Sphinx is a cross-platform framework for developing 2D/3D video ga ...

  7. 自己搭建MVC时遇到的一些问题及解决办法

    错误1 The view 'Index' or its master was not found or no view engine supports the searched locations. ...

  8. HDU - 6098:Inversion(暴力均摊)

    Give an array A, the index starts from 1. Now we want to know B i =max i∤j A j  Bi=maxi∤jAj , i≥2 i≥ ...

  9. eclipse导出文件上传服务器

    [1]导出     选择项目    文件导出 输入导出路径如f盘ftp文件夹下 [2]利用scr上传服务器工具 上传到 home/tomcat/app/项目名称/ 不导入upload文件 [待完善]

  10. test20181219(期末考试)

    Written with StackEdit. \(noip\)爆炸后就好久没考试了...结果今天又被抓去,感觉很慌啊... 考完了.过来填坑. T1 Description 使得\(x^x\)达到或 ...