c++ | O(n) time | using line sweep
Approach: For every \'0\' , save the indexes which can be reached. If we can reach the last index, its value should be greater than 0.\nSimilar concept is used 
Approach: For every \'0\' , save the indexes which can be reached. If we can reach the last index, its value should be greater than 0.\nSimilar concept is used here:\nQuestion: https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/\n\nSolution : https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/discuss/1383003/c%2B%2B-or-O(n)-time-or-using-line-sweep\n```\nclass Solution {\npublic:\nbool canReach(string s, int minJump, int maxJump) {\n    if(s.back()!=\'0\') return false;\n    int n=s.size();\n    vector<int> v(n,0);\n    v[0]=1,v[1]=-1;\n    for(int i=0;i<n;i++){\n        if(i) v[i]+=v[i-1];\n        if(s[i]!=\'0\') continue;\n        if(v[i] && i+minJump<n) v[i+minJump]++;\n        if(v[i] && i+maxJump+1<n) v[i+maxJump+1]--;\n    }\n    return v.back()>0;\n}\n};\n```
[]