āš ļø Blockly failed to load. Check your internet connection and refresh.
Frog Jump
Problem
A frog starts on platform 1 of N platforms. Each platform has a height.

The frog can jump to the next platform (i→i+1) or skip one (i→i+2). The cost of a jump is the absolute difference in heights: |h[destination] āˆ’ h[origin]|.

Find the minimum total cost to reach platform N.
🧠 DP Concept
dp[i] = minimum cost to reach platform i.

Base cases: dp[1] = 0 (you start here for free), dp[2] = |h[2]āˆ’h[1]|.
Recurrence (i ≄ 3):
dp[i] = min( dp[iāˆ’1] + |h[i]āˆ’h[iāˆ’1]|, dp[iāˆ’2] + |h[i]āˆ’h[iāˆ’2]| )

Use the abs block from Math and the min to compare the two options.
Input Variables (pre-loaded)
šŸ’” Use height of platform i to read heights, and dp table blocks to build the solution.
Your Output
Result
—
Run your program to see the result.
Execution Log
Ready. Press ā–¶ Run to start.
Expected Answer
Answer:
?
Hint