O(N) [C++] one pass DP
```\nclass Solution {\npublic:\n    bool canReach(string s,int p1,int p2){\n        int n = s.size() ;\n        vector v ( n , 0 ); // v[i] represents v[i-1] + 
```\nclass Solution {\npublic:\n    bool canReach(string s,int p1,int p2){\n        int n = s.size() ;\n        vector<int> v ( n , 0 ); // v[i] represents v[i-1] + bool( reaching index i )\n        v[0] = 1 ;\n        for(int j = 1 ; j < n ; j++ ) { \n            while( j < n && s[j] == \'1\') {\n                v[j] += v[j-1] ;\n                j++ ;\n            }\n            if( j == n ) break;\n            int imin = max( j - p2 , 0 ) ;\n            int imax = j - p1 ;\n            if (imax < 0 ) v[j] += v[j-1] ;\n            else if( (imin == 0 && v[imax] !=0 )||( imin != 0 && v[imax] - v[imin-1] !=0 ) ) v[j] = 1 + v[j-1] ;\n            else v[j] += v[j-1] ;\n        }\n        return v[n-1]>v[n-2];\n    }\n};
[]