Clean Python 3, BFS
Just prevent to start from repeated positions when performing BFS\nTime: O(N)\nSpace: O(N)\n\n\nimport collections\nclass Solution:\n    def canReach(self, s: s
Just prevent to start from repeated positions when performing BFS\nTime: `O(N)`\nSpace: `O(N)`\n\n```\nimport collections\nclass Solution:\n    def canReach(self, s: str, minJump: int, maxJump: int) -> bool:\n        queue = collections.deque([0])\n        visited, mx = set([0]), 0\n        while queue:\n            i = queue.popleft()\n            for j in range(max(i + minJump, mx + 1), min(i + maxJump + 1, len(s))):\n                if s[j] == \'0\' and j not in visited:\n                    if j == len(s) - 1: return True\n                    queue.append(j)\n                    visited.add(j)\n            mx = max(mx, i + maxJump)\n        return False\n```\n\nEdit: Actually we don\'t need `visited` anymore due to `mx`\n```\nimport collections\nclass Solution:\n    def canReach(self, s: str, minJump: int, maxJump: int) -> bool:\n        queue = collections.deque([0])\n        mx = 0\n        while queue:\n            i = queue.popleft()\n            for j in range(max(i + minJump, mx + 1), min(i + maxJump + 1, len(s))):\n                if s[j] == \'0\':\n                    if j == len(s) - 1: return True\n                    queue.append(j)\n            # mx = max(mx, i + maxJump)\n\t\t\tmx = i + maxJump # thanks @migeater pointd out that it\'s kind of topological sort, which means mx will always be larger while performing BFS\n        return False\n```\n
[]