#1871
Jump Game VII
expert · 1145 · lc medium +32 · verified · 26.4% accepted · 1,805 likes · top 4%
Description
Given a binary string s and two integers minJump and maxJump, you start at index 0 (s[0] == '0'). From any index i with s[i] == '0' you may jump to index j where i + minJump <= j <= min(i + maxJump, s.length - 1) and s[j] == '0'.
Return true if you can reach the last index, or false otherwise.
Example 1:
Input: s = "011010", minJump = 2, maxJump = 3
Output: true
Explanation:
In the first step, move from index 0 to index 3.
In the second step, move from index 3 to index 5.
Example 2:
Input: s = "01101110", minJump = 2, maxJump = 3
Output: false
Code
1
2
3