【Leetcode】Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's tri...

Given a non-negative index kwhere k ≤ 33, return the kthindex row of the Pascal's triangle.

Note that the row index starts from 0.

class Solution(object):

    def getRow(self, rowIndex):

        """

        :type rowIndex: int

        :rtype: List[int]

        """

        row = [1]

        for index in range(1, rowIndex+1):

            row = [1]+[row[x]+row[x-1] for x in range(1, index)] + [1]

        return row

1 list可以用[]相互加起来

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,826评论 0 13
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,693评论 0 10
  • 陌生又熟悉 是一城,作一过客 川流的人海 于千万众之间 无处寻觅 阁窗的灯火 是鱼龙的寂寞 子夜寒露 是寂寞人的蜷...
    一水沚鳶阅读 266评论 2 2
  • 建筑施工生产一直是安全意外事件和安全事故的高发段。那么你对建筑施工安全了解多少呢? 1、建筑施工现场要有交通指示标...
    工程宝阅读 551评论 0 1

友情链接更多精彩内容