From 824ce31f87024fb4d7cc4e4fccdb9c56a761d0cb Mon Sep 17 00:00:00 2001 From: fwqaaq Date: Sat, 27 May 2023 23:28:33 +0800 Subject: [PATCH] =?UTF-8?q?Update=200070.=E7=88=AC=E6=A5=BC=E6=A2=AF?= =?UTF-8?q?=E5=AE=8C=E5=85=A8=E8=83=8C=E5=8C=85=E7=89=88=E6=9C=AC.md=20abo?= =?UTF-8?q?ut=20rust?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...14\345\214\205\347\211\210\346\234\254.md" | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git "a/problems/0070.\347\210\254\346\245\274\346\242\257\345\256\214\345\205\250\350\203\214\345\214\205\347\211\210\346\234\254.md" "b/problems/0070.\347\210\254\346\245\274\346\242\257\345\256\214\345\205\250\350\203\214\345\214\205\347\211\210\346\234\254.md" index 8f8bc9a649..5dde64098d 100644 --- "a/problems/0070.\347\210\254\346\245\274\346\242\257\345\256\214\345\205\250\350\203\214\345\214\205\347\211\210\346\234\254.md" +++ "b/problems/0070.\347\210\254\346\245\274\346\242\257\345\256\214\345\205\250\350\203\214\345\214\205\347\211\210\346\234\254.md" @@ -225,8 +225,25 @@ function climbStairs(n: number): number { }; ``` +Rust: - +```rust +impl Solution { + pub fn climb_stairs(n: i32) -> i32 { + let (n, m) = (n as usize, 2); + let mut dp = vec![0; n + 1]; + dp[0] = 1; + for i in 1..=n { + for j in 1..=m { + if i >= j { + dp[i] += dp[i - j]; + } + } + } + dp[n] + } +} +```