您现在的位置: > 历史 > 战史风云 > 正文

leetcode 119. Pascal's Triangle II bet36备用(杨辉叁角)

2018-09-23 11:57  来源:未知   字号:T | T

  题目:

  ? ? ?

  Given a non-negative?index?k?where?k?≤?33, return the?kth?index row of the Pascal's triangle.

  Note that the row index starts from?0.

  In Pascal's triangle, each number is the sum of the two numbers directly above it.

  Example:

  Follow up:

  Could you optimize your algorithm to use only?O(k) extra space?

  ?

  代码:

  文思:

  叁角中每壹行数为构成中每壹项的值。如第3行是:1,3,3,1。即:

  调用计算老列构成的包 from scipy.special import comb, perm到来计算构成的数值。

  round()函数用到来计算float数值四舍五入的int值的结实。

  ?

  ?

更多