03.04 · Problem
Frog Jump
A frog starts on stone 0 and wants to reach the last stone. From stone i it can jump to i + 1 or i + 2. A jump from i to j costs |heights[i] − heights[j]|. Return the smallest total cost.
Examples
Example 1
Input: heights = [10, 20, 30, 10]
Output: 20
0 → 1 (cost 10) → 3 (cost 10) = 20. Going 0 → 2 → 3 would cost 20 + 20 = 40.
solulu Pro
Continue this problem with Pro
Inside: step-by-step hints · 10 hidden tests · reference solutions · code editor.
Lifetime ₹1,999 ₹999 · Launch offer
Item 23 of 44 · updated 2026-10-13