62. Unique Paths Medium
1/**
2 * [62] Unique Paths
3 *
4 * There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time.
5 * Given the two integers m and n, return the number of possible unique paths that the robot can take to reach the bottom-right corner.
6 * The test cases are generated so that the answer will be less than or equal to 2 * 10^9.
7 *
8 * Example 1:
9 * <img src="https://assets.leetcode.com/uploads/2018/10/22/robot_maze.png" style="width: 400px; height: 183px;" />
10 * Input: m = 3, n = 7
11 * Output: 28
12 *
13 * Example 2:
14 *
15 * Input: m = 3, n = 2
16 * Output: 3
17 * Explanation: From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:
18 * 1. Right -> Down -> Down
19 * 2. Down -> Down -> Right
20 * 3. Down -> Right -> Down
21 *
22 *
23 * Constraints:
24 *
25 * 1 <= m, n <= 100
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/unique-paths/
31// discuss: https://leetcode.com/problems/unique-paths/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn unique_paths(m: i32, n: i32) -> i32 {
37 0
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_62() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.