As reported: ServiceNow Software Engineer (IC2) loop, round 1 (DSA), May 2025: two problems — this one and balancing a bracket string with the fewest swaps. Also asked in an extra problem-solving round of a ServiceNow Staff Software Engineer loop (Feb 2026), together with the shortest window containing a subsequence.
nums[i] is the maximum jump length from index i. Starting at index 0, return the minimum number of jumps needed to reach the last index. The last index is always reachable.
This is LeetCode 45 — Jump Game II.
Example
[2,3,1,1,4] -> 2 (0 → 1 → 4)
[2,3,0,1,4] -> 2
Constraints: 1 ≤ nums.length ≤ 10^4; 0 ≤ nums[i] ≤ 1000; the last index is reachable.
Code runner format: one line with nums as a JSON array. Implement jump(nums); the harness prints the count.