Implement the method minJumpsToEnd that returns the fewest jumps needed to reach the last index.
Each array value tells the maximum number of positions you may jump forward from that index.
The task is designed to test careful handling of edge cases, not only the most common input.
- Use only the first
sizeelements. - Return
0whensizeis1. - Return
-1if the end cannot be reached.
Track the current jump range and farthest reachable index. When the current range ends, take one jump.