Nav: << previous: 61.旋转链表 | next: 63.不同路径 II >>
Description
tab: English
<p>There is a robot on an <code>m x n</code> grid. The robot is initially located at the <strong>top-left corner</strong> (i.e., <code>grid[0][0]</code>). The robot tries to move to the <strong>bottom-right corner</strong> (i.e., <code>grid[m - 1][n - 1]</code>). The robot can only move either down or right at any point in time.</p>
<p>Given the two integers <code>m</code> and <code>n</code>, return <em>the number of possible unique paths that the robot can take to reach the bottom-right corner</em>.</p>
<p>The test cases are generated so that the answer will be less than or equal to <code>2 * 10<sup>9</sup></code>.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<img src="https://assets.leetcode.com/uploads/2018/10/22/robot_maze.png" style="width: 400px; height: 183px;" />
<pre>
<strong>Input:</strong> m = 3, n = 7
<strong>Output:</strong> 28
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> m = 3, n = 2
<strong>Output:</strong> 3
<strong>Explanation:</strong> From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:
1. Right -> Down -> Down
2. Down -> Down -> Right
3. Down -> Right -> Down
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= m, n <= 100</code></li>
</ul>
---
[submissions](https://leetcode.com/problems/unique-paths/submissions/) | [solutions](https://leetcode.com/problems/unique-paths/solutions/)
tab: 中文
<p>一个机器人位于一个 <code>m x n</code><em> </em>网格的左上角 (起始点在下图中标记为 “Start” )。</p>
<p>机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。</p>
<p>问总共有多少条不同的路径?</p>
<p> </p>
<p><strong>示例 1:</strong></p>
<img src="https://pic.leetcode.cn/1697422740-adxmsI-image.png" style="width: 400px; height: 183px;" />
<pre>
<strong>输入:</strong>m = 3, n = 7
<strong>输出:</strong>28</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong>m = 3, n = 2
<strong>输出:</strong>3
<strong>解释:</strong>
从左上角开始,总共有 3 条路径可以到达右下角。
1. 向右 -> 向下 -> 向下
2. 向下 -> 向下 -> 向右
3. 向下 -> 向右 -> 向下
</pre>
<p><strong>示例 3:</strong></p>
<pre>
<strong>输入:</strong>m = 7, n = 3
<strong>输出:</strong>28
</pre>
<p><strong>示例 4:</strong></p>
<pre>
<strong>输入:</strong>m = 3, n = 3
<strong>输出:</strong>6</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= m, n <= 100</code></li>
<li>题目数据保证答案小于等于 <code>2 * 10<sup>9</sup></code></li>
</ul>
---
[提交记录](https://leetcode.cn/problems/unique-paths/submissions/) | [题解](https://leetcode.cn/problems/unique-paths/solution/)
Solutions & Notes
properties:
note.updated:
displayName: Last Updated
note.relative_links:
displayName: Related Links
note.desc:
displayName: Description
note.grade:
displayName: Rating
note.program_language:
displayName: Language
note.time_complexity:
displayName: TC
note.space_complexity:
displayName: SC
views:
- type: table
name: Solutions & Notes
filters:
and:
- file.hasLink(this.file)
- file.tags.containsAny("leetcode/solution", "leetcode/note")
order:
- file.name
- desc
- program_language
- time_complexity
- space_complexity
- grade
- relative_links
- updated
sort:
- property: grade
direction: ASC
- property: time_complexity
direction: ASC
- property: program_language
direction: ASC
columnSize:
file.name: 104
note.space_complexity: 65
note.grade: 126
Similar Problems
properties:
note.lcTopics:
displayName: Topics
note.lcAcRate:
displayName: AC Rate
note.favorites:
displayName: Favorites
note.grade:
displayName: Rating
note.translatedTitle:
displayName: Title (CN)
note.lcDifficulty:
displayName: Difficulty
views:
- type: table
name: Similar Problems
filters:
and:
- file.hasLink(this.file)
- similarQuestions.contains(this.file)
order:
- file.name
- translatedTitle
- lcTopics
- lcDifficulty
- lcAcRate
- grade
- favorites
sort:
- property: file.name
direction: ASC
- property: lcTopics
direction: DESC
columnSize:
note.translatedTitle: 240
note.lcTopics: 347
note.lcAcRate: 75
note.grade: 122