Jump Game VII LeetCode solution in Python
1class Solution:2def canReach(self, s: str, minJump: int, maxJump: int) -> bool:3# dp[i] represents whether i is reachable4dp = [False for _ in s]5dp[0] = True67for i in range(1, len(s)):8if s[i] == "1":9continue1011# iterate through the solutions in range [i - maxJump, i - minJump]12# and if any previous spot in range is reachable, then i is also reachable13window_start = max(0, i - maxJump)14window_end = i - minJump15for j in range(window_start, window_end + 1):16if dp[j]:17dp[i] = True18break1920return dp[-1]