File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 198198- [ 738 Monotone Increasing Digits] ( ./738 )
199199- [ 739 Daily Temperatures] ( ./739 )
200200- [ 740 Delete and Earn] ( ./740 )
201+ - [ 747 Min Cost Climbing Stairs] ( ./747 )
201202- [ 748 Largest Number At Least Twice of Others] ( ./748 )
202203
203204* Q: What is ` LZS ` ? It almost appears inside all files (like js, cpp)?*
You can’t perform that action at this time.
0 commit comments