Check Whether Bounded Jumps Reach the Final Index. Start at index zero of binary string s, whose first character is zero. From i you may jump to a zero-valued position j satisfying i+minJump <= j <= min(i+maxJump,s.length-1).
### Problem
Start at index zero of binary string `s`, whose first character is zero. From i you may jump to a zero-valued position j satisfying `i+minJump <= j <= min(i+maxJump,s.length-1)`. Return whether the final index is reachable.
```cpp
class Solution {
public:
bool canReach(string s, int minJump, int maxJump);
};
```
### Examples
**Example 1:**
```text
s = "00100", minJump = 2, maxJump = 3
Output: false
Explanation: Index 2 is blocked. Index 3 is reachable but cannot jump the single step to index 4.
```
**Example 2:**
```text
s = "010010", minJump = 2, maxJump = 3
Output: true
Explanation: Jump 0 -> 3 -> 5.
```
### Constraints
- `2 <= s.length <= 10^5`.
- Characters are 0 or 1, and `s[0] == 0`.
- `1 <= minJump <= maxJump < s.length`.
### Clarifying Questions
Only landing positions must contain zero; positions jumped over can contain either digit. The last character need not be zero.
```hint Inspect the structure
Which landing positions are legal, and does the input promise that the final character is zero?
```
### Reasoning checkpoints
- Require every landing to contain zero and every jump length to stay within the inclusive bounds.
- Prove both reachability and unreachability claims without restricting cells jumped over.
### Optional extensions
How could prefix sums of reachability replace the sliding predecessor count?
Overview: Check Whether Bounded Jumps Reach the Final Index. Start at index zero of binary string s, whose first character is zero. From i you may jump to a zero-valued position j satisfying i+minJump <= j <= min(i+maxJump,s.length-1).
Start at index zero of binary string s, whose first character is zero. From i you may jump to a zero-valued position j satisfying i+minJump <= j <= min(i+maxJump,s.length-1). Return whether the final index is reachable.
class Solution {
public:
bool canReach(string s, int minJump, int maxJump);
};
Examples
Example 1:
s = "00100", minJump = 2, maxJump = 3
Output: false
Explanation: Index 2 is blocked. Index 3 is reachable but cannot jump the single step to index 4.