[Java] Binary Search Time: O(nLogn)
We can go through the index one by one. Skip if it is 1. For index j and s[j] == \'0\', we just need to ask whether there is an 0 at index between j-maxJump and
We can go through the index one by one. Skip if it is `1`. For index `j` and `s[j] == \'0\'`, we just need to ask whether there is an `0` at index between `j-maxJump` and `j - minJump`\n\nTime: `O(nLogn)`\n\n```\nclass Solution {\n    public boolean canReach(String s, int minJump, int maxJump) {\n        int n = s.length();\n        if (s.charAt(n-1) != \'0\') return false;\n        //Let\'s go through index in s one by one and check whether there is before visited number that is in the range\n        //[j-maxJump, j-minJump], so this become a problem of treeSet\n        //We can add visited node into tree set\n        TreeSet<Integer> visited = new TreeSet<>();\n        visited.add(0);\n        for (int j = 1; j < n; j++) {\n            if (s.charAt(j) == \'0\') {\n                int left = j-maxJump, right = j-minJump;\n                Integer key = visited.floor(right);\n                if (key != null && key >= left) {\n                    if (j == n-1) return true;\n                    visited.add(j);\n                }\n            }\n        }\n        return false;\n    }\n}\n```
[]