Skip to content

Commit 4f59de6

Browse files
authored
Create Solution3.rs
1 parent a25333d commit 4f59de6

File tree

1 file changed

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

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
impl Solution {
2+
pub fn min_cost_climbing_stairs(cost: Vec<i32>) -> i32 {
3+
let (mut f, mut g) = (0, 0);
4+
for i in 2..=cost.len() {
5+
let gg = std::cmp::min(f + cost[i - 2], g + cost[i - 1]);
6+
f = g;
7+
g = gg;
8+
}
9+
g
10+
}
11+
}

0 commit comments

Comments
 (0)