My 8 line code was accepted. Can someone improve or provide a failure case?

  • -6

    class Solution:
    def log_factorial(self, x):
    ans = 0
    for i in range(x):
    ans += math.log(x-i)
    return ans
    def uniquePaths(self, m, n):
    return int(round( math.exp( self.log_factorial(m+n-2) - self.log_factorial(m-1) - self.log_factorial(n-1) ) ))

Log in to reply

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