内容简介:如果当前没有针对性的话,那就从头把之前补上。
2 0 1 9 -5 -28 星 期二 开 始 吧
如果当前没有针对性的话,那就从头把之前补上。
上 一 题 链 接 Leetcode基础刷题之 PHP 解析(66. Plus One)
题 目 描 述
给定一个行数,生成杨辉三角形。
题 目 分 析
生成这样的三角形是有规律的,每一行的首尾的值都是1,从第三行开始,中间的每一位数都是前一行左右数之和。
/**
* @param Integer $numRows
* @return Integer[][]
*/
function generate($numRows) {
$res=[];
for($i=0;$i<$numRows;$i++){
for($j=0;$j<=$i;++$j){
if($i==0 && $j==0) $res[0][0]=1;
else $res[$i][$j]=$res[$i-1][$j-1]+$res[$i-1][$j];
}
}
return $res;
}
Github整理地址: https://github.com/wuqinqiang/leetcode-php
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Apache Flink 零基础入门(一):基础概念解析
- Apache Flink 零基础入门(一):基础概念解析
- JStorm 源码解析:基础线程模型
- React Hooks 解析(上):基础
- TypeScript基础入门之模块解析(一)
- TypeScript基础入门之模块解析(二)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Everything Store
Brad Stone / Little, Brown and Company / 2013-10-22 / USD 28.00
The definitive story of Amazon.com, one of the most successful companies in the world, and of its driven, brilliant founder, Jeff Bezos. Amazon.com started off delivering books through the mail. Bu......一起来看看 《The Everything Store》 这本书的介绍吧!