Final exam — Dynamic Programming
Three unseen problems (not covered in the lessons) to test whether you leave this section able to solve any problem of the topic: one easy, one medium and one hard. Some test cases are hidden — like the real LeetCode. Solve in Python or JavaScript.
Min Cost Climbing Stairs
Each step i has a cost cost[i]. You can climb 1 or 2 steps at a time, and start from step 0 or step 1. Return the minimum cost to reach the top (beyond the last step).
Example: [10,15,20] → 15 (start at step 1, pay 15, and climb 2 to the top).
Partition Equal Subset Sum
Given an array nums of positive integers, return true if it can be split into two subsets with equal sum.
Example: [1,5,11,5] → true ([1,5,5] and [11], both sum to 11).
Edit Distance
Given two words word1 and word2, return the minimum number of operations (insert, remove, or replace a character) to transform one into the other.
Example: "horse" → "ros" → 3 (remove 'h', replace 'r'→'r'… in practice: rose, ros... 3 operations).