Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.18 KB

119.md

File metadata and controls

43 lines (32 loc) · 1.18 KB

✏️Leetcode基础刷题之(119. Pascal's Triangle II)

2019-05-29 吴亲库里 库里的深夜食堂


✏️描述

这道题和上一道题有一点不同的是返回给定行数的各个值。

✏️题目实例

✏️题目分析

图中我们也能知道给定多少行,当前行就有多少个数。把昨天的变动一下,就是今天的需求

✏️具体实现

       /**
           * @param Integer $rowIndex
           * @return Integer[]
           */
          function getRow($rowIndex) {
              $res[0]=1;
              for($i=1;$i<=$rowIndex;$i++){
                  for($j=$i;$j>=0;$j--){
                      $res[$j] +=$res[$j-1];
                  }
              }
              return $res;
          }

联系