You've seen how to count paths. Now I'll show you how to improve cost. In Min Cost Climbing Stairs (LeetCode ), each step has a cost[i] you pay when leaving it.
You can start at step or , and climb or steps at a time. Goal: reach the top (past the last step) with minimum total cost. Example: cost = [10, 15, 20]. Starting at index costs , then jump to the top, total . Starting at index costs , then jump to the top, total . Best answer: .