Simple C++ O(N) solution  |   DP + sliding window  |  completely explained in comments
\nclass Solution {\npublic:\n    bool canReach(string s, int minJ, int maxJ) {\n        int n=s.length();\n        if(s[n-1]==\'1\') return false;//if last char
```\nclass Solution {\npublic:\n    bool canReach(string s, int minJ, int maxJ) {\n        int n=s.length();\n        if(s[n-1]==\'1\') return false;//if last char is 1 we can never reach it\n        \n        //from any index (i-maxJ) to (i-minJ) we can reach i (acc to condition 1)\n        //so (i-maxJ) to (i-minJ) acts as a window for index i\n        \n        //but i can be less than maxJ, then window is from 0 to i-minJ -> variable size window\n        // Similarly i may be less than minJ. Then no window\n        //So its better to handle these 2 cases initially as shown below\n        \n        vector<bool> dp(n);\n        //dp[i]=true if we can reach i from 0 index by doing valid jumps. False otherwise\n        dp[0]=true;\n        \n        //From 0 index we have to make a jump of atleast minJ, so the least index i can \n        // reach from 0 is index minJ. So we cannot reach indices from 1 to (minJ-1)\n        for(int i=1;i<minJ;i++){\n            dp[i]=false;\n        }\n        \n        // from 0 index we can directy make any jump from len minJ to maxJ\n        //so from 0 We can reach indices minJ to maxJ satisfying condition 1\n        for(int i=minJ;i<maxJ;i++){\n            dp[i] = (s[i]==\'0\')?true:false;\n        }\n        //maxJ handled below\n        \n        //now i>=maxJ\n        //window is from (i-maxJ) to (i-minJ) on dp array and it remains constant in size\n        //so we can simply use the sliding window concept\n        \n        int ct=0;//count of number of true in window\n        //initial value of ct\n        for(int j=0;j<=(maxJ-minJ);j++){\n            if(dp[j]) ct++;\n        }\n        \n        for(int i=maxJ;i<n;i++){\n            if(ct > 0 && s[i]==\'0\') dp[i]=true;\n            else{\n                 dp[i]=false;\n            }\n            \n            //slide window 1 place forward\n            if(dp[i-maxJ]) ct--;\n            \n            if(dp[i-minJ+1]) ct++;\n        }\n        return dp[n-1];\n    }\n};\n```
['Dynamic Programming', 'C', 'Sliding Window']