4 lines pythonic easy solution, O(k) space, 40ms


  • 2
    J
    def getRow(rowIndex):
        """
        :type rowIndex: int
        :rtype: List[int]
        """
        row = [1]
        for i in range(rowIndex):
            row = [u+v for u, v in zip(row+[0], [0]+row)]
        return row

Log in to reply
 

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