One line Python solution


  • 1
    T
    def uniquePaths(self, m, n):
        """
        :type m: int
        :type n: int
        :rtype: int
        """
        return math.factorial(m+n-2)/(math.factorial(m-1)*math.factorial(n-1))
    

    We have m-1,n-1 identical things to arrange, this can be done in (m+n-2)!/(m-1)!(n-1)!


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.