class Solution:
    def uniquePaths(self, m: int, n: int) -> int:
        dp=[[1 for _ in range(n+1)] for _ in range(m+1)]
        for i in range(2,m+1):
            for j in range(2,n+1):
                dp[i][j]=dp[i-1][j]+dp[i][j-1]

        return dp[m][n]

    def uniquePaths_dfs(self, m: int, n: int) -> int:
        def dfs(i,j):
            if i>m-1 or j>n-1:
                return
            
            if i==m-1 and j==n-1:
                self.ret+=1
            dfs(i+1,j)
            dfs(i,j+1)
        self.ret=0
        dfs(0,0)
        return self.ret