Jump Game VII

You are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. You can move from index i to index j if the following conditions are fulfilled:

  • i + minJump <= j <= min(i + maxJump, s.length - 1)
  • s[j] == '0'

Return true if you can reach index s.length - 1 in s, or false otherwise.

Example 1
Inputs = "011010", minJump = 2, maxJump = 3
Outputtrue
In the first step, move from index 0 to index 3, and in the second step, move from index 3 to index 5.
Example 2
Inputs = "01101110", minJump = 2, maxJump = 3
Outputfalse
There is no sequence of valid jumps that reaches the last index.

Constraints

  • 2 <= s.length <= 10^5
  • s[i] is either '0' or '1'.
  • s[0] == '0'
  • 1 <= minJump <= maxJump < s.length

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate