Tricky recursive solution in Python.


  • 0
    Z
    class Solution(object):
        def uniquePaths(self, m, n):
            """
            :type m: int
            :type n: int
            :rtype: int
            """
            def uPath(x, y):
                if x == 1:
                    return 1
                elif y == 1:
                    return 1
                else:
                    return uPath(x-1,y)+uPath(x,y-1)
            
            return uPath(m,n)
    

  • 0
    Z

    But when m=23 and n=12, TLE is raised:-(


Log in to reply
 

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