We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fa58696 commit be711f2Copy full SHA for be711f2
747/main.go
@@ -0,0 +1,18 @@
1
+func min(a, b int) int {
2
+ if a < b {
3
+ return a
4
+ }
5
+ return b
6
+}
7
+
8
+func minCostClimbingStairs(cost []int) int {
9
+ if len(cost) <= 1 {
10
+ return 0
11
12
+ dp := make([]int, len(cost))
13
+ dp[0], dp[1] = cost[0], cost[1]
14
+ for i := 2; i < len(cost); i++ {
15
+ dp[i] = min(dp[i-1], dp[i-2]) + cost[i]
16
17
+ return min(dp[len(cost)-1], dp[len(cost)-2])
18
README.md
@@ -198,6 +198,7 @@
198
- [738 Monotone Increasing Digits](./738)
199
- [739 Daily Temperatures](./739)
200
- [740 Delete and Earn](./740)
201
+- [747 Min Cost Climbing Stairs](./747)
202
- [748 Largest Number At Least Twice of Others](./748)
203
204
*Q: What is `LZS`? It almost appears inside all files (like js, cpp)?*
0 commit comments