leetcode 5.4
45、跳跃游戏
class Solution
{
public:
int jump(vector<int>& nums)
{
int temp = nums[0];
int start = 0;
int end = 0;
int count = 0;
int len = nums.size() - 1;
while (temp < len)
{
for (int i = start; i <= end; i++)
{
int temp1 = nums[i] + i;
temp = (temp >temp1 ? temp : temp1);
}
start = end + 1;
end = temp;
count++;
}
return count;
}
};
如果你是对的,那就证明给他们看!

浙公网安备 33010602011771号