内容简介:如果当前没有针对性的话,那就从头把之前补上。
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基础入门之模块解析(二)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
C++ Concurrency in Action
Anthony Williams / Manning Publications / 2012-2-28 / USD 69.99
HIGHLIGHT C++ Concurrency in Action is the first book to market to show how to take advantage of the new C++ Standard and how to write robust multi-threaded applications in C++. DESCRIPTION With ......一起来看看 《C++ Concurrency in Action》 这本书的介绍吧!
RGB转16进制工具
RGB HEX 互转工具
RGB CMYK 转换工具
RGB CMYK 互转工具