LeetCode-Jump Game II

来源:互联网 发布:node解决跨域问题 编辑:程序博客网 时间:2024/04/30 00:54
class Solution {public:    int jump(int A[], int n) {        // Start typing your C/C++ solution below        // DO NOT write int main() function        int end = n - 1;        int steps = 0;        while (end > 0)        {            for (int i = 0; i < end; ++i)            {                if (A[i] >= end - i)                {                    ++steps;                    end = i;                    break;                }            }        }        return steps;    }};

原创粉丝点击