solution.json 1.8 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{
  "type": "code_options",
  "author": "https://github.com/qiyuangong/leetcode",
  "source": "solution.md",
  "exercise_id": "0a12ae6577704d18b37db6956fe16aa8",
  "keywords": "记忆化搜索,数学,动态规划",
  "title": "爬楼梯",
  "desc": [
    {
      "content": "\n<p>假设你正在爬楼梯。需要 <em>n</em>&nbsp;阶你才能到达楼顶。</p><p>每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?</p><p><strong>注意:</strong>给定 <em>n</em> 是一个正整数。</p><p><strong>示例 1:</strong></p><pre><strong>输入:</strong> 2<strong><br />输出:</strong> 2<strong><br />解释:</strong> 有两种方法可以爬到楼顶。1.  1 阶 + 1 阶2.  2 阶</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong> 3<strong><br />输出:</strong> 3<strong><br />解释:</strong> 有三种方法可以爬到楼顶。1.  1 阶 + 1 阶 + 1 阶2.  1 阶 + 2 阶3.  2 阶 + 1 阶</pre>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "python"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ]
  ],
  "template": {
    "content": "class Solution(object):\n\tdef climbStairs(self, n):\n\t\tif n <= 1:\n\t\t\treturn 1\n\t\tdp = [1] * 2\n\t\tfor i in range(2, n + 1):\n\t\t\tdp[1], dp[0] = dp[1] + dp[0], dp[1]\n\t\treturn dp[1]\n# %%\ns = Solution()\nprint(s.climbStairs(2))",
    "language": "python"
  },
  "node_id": "dailycode-40b9002d2beb42aeabf9947bc8af5932",
  "license": "csdn.net",
  "created_at": 1637894161,
  "topic_link": "https://bbs.csdn.net/topics/600470125"
}