BFS - C++ Explained
-> If last character is not \'0\' , return false\n\nAssuming i has current position where we are standing and using standard BFS approach with slight optimizati
-> If last character is not \'0\' , return false\n\nAssuming i has current position where we are standing and using standard BFS approach with slight optimization (to avoid TLE).\n\n**Slight Optimization** : I got TLE with standard BFS so added this to avoid extra traversals.\n-> max_curr : max position which has been visited  till previous iteration , start next iteration after max_curr to avoid duplication indices traversals.\n\n1. Initially i = 0 , insert i into queue.\n2. Pop i from queue front \n3. Iterate from max (i+minJump,max_curr) to (i+maxJump) and put all 0s indices in queue.\n4. Update max_curr after complete iteration.\n\n```\nclass Solution {\npublic:\n    bool canReach(string s, int minJump, int maxJump) {\n        int n = s.length();\n        if(s[n-1]!=\'0\')\n            return false;\n        \n        int i = 0;\n        queue<int> q;\n        q.push(0);\n        int curr_max = 0;\n        \n        while(!q.empty()){\n            i = q.front();\n            q.pop();\n            if(i == n-1)\n                return true;\n            \n            for(int j = max(i + minJump, curr_max); j <= min(i + maxJump, n - 1); j++){\n                if(s[j] == \'0\')   q.push(j);\n            }   \n            curr_max = min(i+maxJump+1, n);\n        }\n        return false;\n    }\n};\n```\n\n**Time Complexity** - O(n)
['Greedy', 'Breadth-First Search', 'C', 'C++']