Class Solution

java.lang.Object
g0001_0100.s0062_unique_paths.Solution

public class Solution extends Object
62 - Unique Paths.<p>Medium</p> <p>A robot is located at the top-left corner of a <code>m x n</code> grid (marked &lsquo;Start&rsquo; in the diagram below).</p> <p>The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked &lsquo;Finish&rsquo; in the diagram below).</p> <p>How many possible unique paths are there?</p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2018/10/22/robot_maze.png" alt="" /></p> <p><strong>Input:</strong> m = 3, n = 7</p> <p><strong>Output:</strong> 28</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> m = 3, n = 2</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong></p> <pre><code> 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 </code></pre> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> m = 7, n = 3</p> <p><strong>Output:</strong> 28</p> <p><strong>Example 4:</strong></p> <p><strong>Input:</strong> m = 3, n = 3</p> <p><strong>Output:</strong> 6</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= m, n <= 100</code></li> <li>It&rsquo;s guaranteed that the answer will be less than or equal to <code>2 * 10<sup>9</sup></code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • uniquePaths

      public int uniquePaths(int m, int n)