Leetcode fifty-five questions (jumping games)

share picture

 class Solution {

public:
bool canJump(vector<int>& nums) {
int len=nums.size();
if(len==1)//Border border border!
return true ;

int max_bianjie=nums[0];//Set a boundary, initialized to 0+nums[0]
for(int i=0;i)
{
if(i+1+nums[i+1]>max_bianjie)//If i+1 is within the boundary, and i+1+nums[i+1]>max_bianjie, update the boundary
max_bianjie=i+1+nums[i+1];

if(max_bianjie>=len-1)< span style="color: #008000;">//If the border overflows, return true
return true ;
}
return false;
}
};

Analysis:

The hand feel is still very poor.

class Solution {

public:
bool canJump(vector<int>& nums) {
int len=nums.size();
if(len==1)//Border border border!
return true ;

int max_bianjie=nums[0];//Set a boundary, initialized to 0+nums[0]
for(int i=0;i)
{
if(i+1+nums[i+1]>max_bianjie)//If i+1 is within the boundary, and i+1+nums[i+1]>max_bianjie, update the boundary
max_bianjie=i+1+nums[i+1];

if(max_bianjie>=len-1)< span style="color: #008000;">//If the border overflows, return true
return true ;
}
return false;
}
};

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1711 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.