746. Min Cost Climbing Stairs Easy
1/**
2 * [746] Min Cost Climbing Stairs
3 *
4 * You are given an integer array cost where cost[i] is the cost of i^th step on a staircase. Once you pay the cost, you can either climb one or two steps.
5 * You can either start from the step with index 0, or the step with index 1.
6 * Return the minimum cost to reach the top of the floor.
7 *
8 * Example 1:
9 *
10 * Input: cost = [10,<u>15</u>,20]
11 * Output: 15
12 * Explanation: You will start at index 1.
13 * - Pay 15 and climb two steps to reach the top.
14 * The total cost is 15.
15 *
16 * Example 2:
17 *
18 * Input: cost = [<u>1</u>,100,<u>1</u>,1,<u>1</u>,100,<u>1</u>,<u>1</u>,100,<u>1</u>]
19 * Output: 6
20 * Explanation: You will start at index 0.
21 * - Pay 1 and climb two steps to reach index 2.
22 * - Pay 1 and climb two steps to reach index 4.
23 * - Pay 1 and climb two steps to reach index 6.
24 * - Pay 1 and climb one step to reach index 7.
25 * - Pay 1 and climb two steps to reach index 9.
26 * - Pay 1 and climb one step to reach the top.
27 * The total cost is 6.
28 *
29 *
30 * Constraints:
31 *
32 * 2 <= cost.length <= 1000
33 * 0 <= cost[i] <= 999
34 *
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/min-cost-climbing-stairs/
39// discuss: https://leetcode.com/problems/min-cost-climbing-stairs/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44 pub fn min_cost_climbing_stairs(cost: Vec<i32>) -> i32 {
45 0
46 }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 #[test]
56 fn test_746() {
57 }
58}
59
Back
© 2025 bowen.ge All Rights Reserved.