Two Pointers and Sliding Window
I struggled a bit with this problem - I used memoisation and marked positions as \'visited\', and still got TLE. \n \n#### Approach 1: Two Pointers\nIn the two 
I struggled a bit with this problem - I used memoisation and marked positions as \'visited\', and still got TLE. \n \n#### Approach 1: Two Pointers\nIn the two pointers pattern, we move `i` left to right, and jump from `i` to `j`. This pattern could help observe an important fact: we only need to increase `j`. \n\nThe reason is that we already attempted jumps to all positions prior to `j`. This leads to an O(n) solution.\n\n**C++**\n```cpp\nbool canReach(string s, int minJump, int maxJump) {\n    for (int i = 0, j = 0; i < s.size(); ++i)\n        if (i == 0 || s[i] == \'2\')\n            for (j = max(j, i + minJump); j <= min((int)s.size() - 1, i + maxJump); ++j)\n                if (s[j] == \'0\')\n                    s[j] = \'2\';\n    return s[s.size() - 1] == \'2\';\n} \n```\n\n#### Approach 2: Sliding Window\nPosition `i` is reachable if we\'ve reached any position between `[i - maxJump, i - minJump]`. \n\nSo, we can move `i` left to right, and use the sliding window pattern to count reachable positions. If `s[i] == \'0\'`, and count is positive - we mark position `i` as reachable.\n\n**C++**\n```cpp\nbool canReach(string s, int minJump, int maxJump) {\n    int cnt = 0;\n    vector<bool> dp(s.size());\n    dp[0] = true;\n    for (int i = minJump; i < s.size(); ++i) {\n        cnt += dp[i - minJump];\n        if (i - maxJump > 0)\n            cnt -= dp[i - maxJump - 1];\n        dp[i] = s[i] == \'0\' && cnt;\n    }\n    return dp.back();\n}  \n```
['C']