Complete the code to check if the array is empty and return true.
if (nums.length [1] 0) return true;
We check if the length of the array is exactly 0 to return true immediately.
Complete the code to update the farthest reachable index.
farthest = Math.[1](farthest, i + nums[i]);We use Math.max to keep track of the farthest index we can jump to.
Fix the error in the loop condition to avoid index out of bounds.
for (int i = 0; i [1] nums.length; i++) {
The loop should run while i is less than nums.length to avoid going out of bounds.
Fill both blanks to check if current index is reachable and update farthest jump.
if (i [1] farthest) { farthest = Math.[2](farthest, i + nums[i]); }
We check if i is less than or equal to farthest reachable index, then update farthest using Math.max.
Fill all three blanks to return true if last index is reachable, else false.
return farthest [1] nums.length [2] 1; // or return farthest [3] nums.length - 1;
We check if farthest is greater than or equal to last index (nums.length - 1). The '+' in second line is part of expression 'nums.length + 1' which is incorrect, so correct is to use '-' in actual code. Here, the blanks show the correct operators to form the condition.
