Description Given an index k, return the kth row of the Pascal’s triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? Code
编辑代码 2000ms 262144K Generalized Pascal's Triangle Pascal's triangle is a triangular array in which each number can be calculated by the sum of the two numbers directly above that number as shown i
119. Pascal’s Triangle II Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal’s triangle. In Pascal’s triangle, each number is the sum of the two numbers directly above it
题目: Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1]. 思路: 要求是返回帕斯卡某一行的数据设置两个list变量,pre和next,pre用来存储当前的最后的最后一行,next存储下一行,next赋值给pre(在这之前pre清空,
题目: Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] 思路 题意是要用数组表示帕斯卡三角形输入一个数值,显示相应行数的【帕斯卡三角形根据下一行和上一行