Java | Queue solution | O(n)
We keep looking for index of \'0\', in each \'0\', we compare its index with previous possible index. \n\n1. if the index in queue is smaller than i - maxJump w
We keep looking for index of \'0\', in each \'0\', we compare its index with previous possible index. \n\n1. if the index in queue is smaller than i - maxJump which means we will never use it later, just poll it.\n2. After polling, the first element will be the most possible index which can jump to this position. We compare it.\n\nWhen we jump to n - 1, return true;\nwhenever, the queue is empty, we return false since there is no place to stand.\n\n\n\tclass Solution {\n    public boolean canReach(String s, int minJump, int maxJump) {\n        int n = s.length();\n        Queue<Integer> queue = new LinkedList<>();\n        queue.offer(0);\n        \n        for (int i = 0; i < n && i != -1; i = s.indexOf("0", i + 1)) {\n            while(!queue.isEmpty() && queue.peek() < i - maxJump) queue.poll();\n            \n            if (!queue.isEmpty() && i - queue.peek() >= minJump && i - queue.peek() <= maxJump) {\n                queue.offer(i);\n                if (i == n - 1) return true;\n            }\n            if (queue.isEmpty()) return false;\n        }\n        return false;\n    }\n\t}
[]