> For the complete documentation index, see [llms.txt](https://sisyphus.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sisyphus.gitbook.io/project/leetcode-notes/dynamic-programming/unique-path.md).

# Unique Path

```python
class Solution(object):
    def uniquePaths(self, m, n):
        """
        :type m: int
        :type n: int
        :rtype: int
        """
        if m > n:
            m, n = n, m

        dp = [1] * m
        for i in range(1, n):
            for j in range(1, m):
                dp[j] = dp[j - 1] + dp[j]
        return dp[-1]
```
