Binomial Coefficient 40 ms runtime beats 91.77 % of Python 3 submissions.


  • 0
    M

    Binomial Coefficient 40 ms runtime beats 91.77 % of Python 3 submissions.

    class Solution:
        def factorial(self, n):
            if n in [0, 1]:
                return 1
            return n * Solution.factorial(self, n - 1)
    
        def getRow(self, n):
            """
            :type rowIndex: int
            :rtype: List[int]
            """
            row = []
            for k in range(n + 1):
                row.append(self.factorial(n) // (self.factorial(k) * self.factorial(n - k)))
            return row
    

    https://www.wikiwand.com/en/Binomial_coefficient


Log in to reply
 

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