one pass || Prefix / Suffix sum || C++
\nclass Solution {\npublic:\n    bool canReach(string s, int minJump, int maxJump) \n    {\n        int n = s.length();\n        if(s[n-1]==\'1\') return false;
```\nclass Solution {\npublic:\n    bool canReach(string s, int minJump, int maxJump) \n    {\n        int n = s.length();\n        if(s[n-1]==\'1\') return false;\n        \n        vector<int> preSum(n,0);\n        \n        int sum = 1;\n        preSum[n-1] = 1;\n        int res;\n        bool ans;\n        \n        for(int i=n-1 ; i>=0 ; i--)\n        {\n            res = 0;\n            \n            if(s[i]==\'0\')\n            {\n                if(i+minJump < n)\n                {\n                    if(i+maxJump >= n-1)\n                    {\n                        res = preSum[i+minJump] ;\n                    }\n                    else\n                    {\n                        res = preSum[i+minJump] - preSum[i+maxJump+1];\n                    }\n                }\n            }\n            \n            if(res) sum++;\n            ans = res;\n            preSum[i] = sum;\n        }\n        \n        return ans;\n    }\n};\n```
[]