diff --git "a/problems/0070.\347\210\254\346\245\274\346\242\257.md" "b/problems/0070.\347\210\254\346\245\274\346\242\257.md" index f0a08f9916..3f14075ff0 100644 --- "a/problems/0070.\347\210\254\346\245\274\346\242\257.md" +++ "b/problems/0070.\347\210\254\346\245\274\346\242\257.md" @@ -212,6 +212,22 @@ public: Java: +```Java +class Solution { + public int climbStairs(int n) { + // 跟斐波那契数列一样 + if(n <= 2) return n; + int a = 1, b = 2, sum = 0; + + for(int i = 3; i <= n; i++){ + sum = a + b; + a = b; + b = sum; + } + return b; + } +} +``` Python: