[Python3] prefix sum
\n\nclass Solution:\n    def canReach(self, s: str, minJump: int, maxJump: int) -> bool:\n        prefix = [0, 1]\n        for i in range(1, len(s)): \n        
\n```\nclass Solution:\n    def canReach(self, s: str, minJump: int, maxJump: int) -> bool:\n        prefix = [0, 1]\n        for i in range(1, len(s)): \n            prefix.append(prefix[-1])\n            lo = max(0, i-maxJump)\n            hi = max(0, i-minJump+1)\n            if s[i] == "0" and prefix[hi] - prefix[lo] > 0: prefix[-1] += 1\n        return prefix[-1] > prefix[-2] \n```\n\nAdding bfs \n```\nclass Solution:\n    def canReach(self, s: str, minJump: int, maxJump: int) -> bool:\n        queue, lo = [0], 0\n        for x in queue: \n            if x == len(s)-1: return True \n            for xx in range(max(lo+1, x+minJump), min(x+maxJump+1, len(s))): \n                if s[xx] == "0": queue.append(xx)\n            lo = max(lo, x + maxJump)\n        return False \n```\n\na bit hack-ish\n```\nclass Solution:\n    def canReach(self, s: str, minJump: int, maxJump: int) -> bool:\n        lo = 0 \n        can = [1] + [0]*(len(s)-1)\n        for i, x in enumerate(s): \n            if x == "0" and can[i]: \n                for ii in range(max(lo+1, i+minJump), min(i+maxJump+1, len(s))): \n                    if s[ii] == "0": can[ii] = 1\n                    lo = max(lo, i+maxJump) # key to pass \n        return can[len(s)-1] \n```\n\nAdding Union-Find per @zdu011\n```\nclass UnionFind: \n    def __init__(self, n): \n        self.parent = list(range(n))\n        \n    def find(self, p):\n        if p != self.parent[p]: \n            self.parent[p] = self.find(self.parent[p])\n        return self.parent[p]\n    \n\nclass Solution:\n    def canReach(self, s: str, minJump: int, maxJump: int) -> bool:\n        uf = UnionFind(len(s))\n        for i, x in enumerate(s): \n            if x == "0": \n                lo, hi = i+minJump, min(len(s), i+maxJump+1)\n                if lo < len(s): uf.parent[i] = lo = uf.find(lo)\n                while lo+1 < hi: \n                    uf.parent[lo] = lo+1\n                    lo = uf.find(lo)\n        return uf.find(0) == uf.find(len(s)-1) and s[-1] == "0"\n```
['Python3']