• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

给你一个整数数组nums .您最初位于数组的第一个索引处,数组中的每个元素都代表您在该位置的最大跳转长度。

如果可以到达最后一个索引,则返回没错,否则返回错误.

Solution

每次计算最远能走到的位置,时间复杂度\(O(n)\)

点击查看代码类别解决方案{

公共:

布尔可以跳(矢量数字){

int n=nums。size();

如果(n==1)返回真实的

否则{

int max _ reach=0;

for(int I=0;在;i ){

if(imax_reach)返回错误的

max_reach=max(max_reach,I nums);

}

返回真实的

}

}

};

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now