标签:style blog color io div amp log leetcode
A simulation problem. We simple walk through all reachable items until we cannot proceed.
class Solution { public: bool canJump(int A[], int n) { int MaxInx = 0; int inx = 0; while (inx < n && inx <= MaxInx) { MaxInx = std::max(MaxInx, A[inx] + inx); if (MaxInx >= n - 1) return true; inx++; } return false; } };
LeetCode "Jump Game",布布扣,bubuko.com
标签:style blog color io div amp log leetcode
原文地址:http://www.cnblogs.com/tonix/p/3884480.html