Skip to content

Commit 5242505

Browse files
authored
Create Solution3.go
1 parent adbafb6 commit 5242505

File tree

1 file changed

+7
-0
lines changed
  • solution/0700-0799/0746.Min Cost Climbing Stairs

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
func minCostClimbingStairs(cost []int) int {
2+
var f, g int
3+
for i := 2; i <= n; i++ {
4+
f, g = g, min(f+cost[i-2], g+cost[i-1])
5+
}
6+
return g
7+
}

0 commit comments

Comments
 (0)