Jump Game VII - Problem
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), ands[j] == '0'
Return true if you can reach index s.length - 1 in s, or false otherwise.
Input & Output
Example 1 — Basic Jump Sequence
$
Input:
s = "011010", minJump = 2, maxJump = 3
›
Output:
true
💡 Note:
Start at index 0, jump to index 3 (jump of size 3), then jump to index 5 (jump of size 2). Both positions contain '0' and are within jump constraints.
Example 2 — Blocked Path
$
Input:
s = "01101110", minJump = 2, maxJump = 3
›
Output:
false
💡 Note:
From index 0, we can reach index 2 or 3. From index 3, we can reach indices 5 or 6, but both contain '1'. No valid path to the last index.
Example 3 — Minimum Jump Only
$
Input:
s = "0101", minJump = 1, maxJump = 1
›
Output:
false
💡 Note:
From index 0, jump to index 1 ('1' - invalid). Cannot proceed further, so cannot reach index 3.
Constraints
- 2 ≤ s.length ≤ 105
- s[i] is either '0' or '1'
- s[0] == '0'
- 1 ≤ minJump ≤ maxJump < s.length
Visualization
Tap to expand
Understanding the Visualization
1
Input
Binary string with jump constraints
2
Process
Find valid jumps avoiding '1' positions
3
Output
True if last position is reachable
Key Takeaway
🎯 Key Insight: Use sliding window with DP to efficiently track which positions can jump to current position
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code