Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Jump Game II

Medium
greedyarraybfs

Same setup as Jump Game, but reaching the last index is guaranteed. Return the minimum number of jumps needed.

Input: one line of space-separated non-negative integers. Output: the minimum jump count.

Example 1
Input:
2 3 1 1 4
Output:
2

0→1 then 1→4.

Example 2
Input:
2 3 0 1 4
Output:
2

Constraints

  • 1 ≤ nums.length ≤ 10^4
  • Reaching the end is always possible.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.