博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode 119 Pascal's Triangle II
阅读量:4330 次
发布时间:2019-06-06

本文共 664 字,大约阅读时间需要 2 分钟。

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:

 

c++:

class Solution {public:    vector
getRow(int rowIndex) { vector
> triangle; int j=1; for(int i=0;i<=rowIndex;i++) { vector
a; for(int k=0;k

 

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


 
 

转载于:https://www.cnblogs.com/dacc123/p/9315897.html

你可能感兴趣的文章
《将博客搬至CSDN》
查看>>
异常的基本概念
查看>>
Educational Codeforces Round 4 C. Replace To Make Regular Bracket Sequence
查看>>
.Net 程序脱壳
查看>>
asp.net文本编辑器(FCKeditor)
查看>>
SEnet --se module
查看>>
【OpenStack】OpenStack系列8之Nova详解 Neutron详解
查看>>
[翻译]理解分析Linux里的101个ELF文件
查看>>
iOS Programming Subclassing UITableViewCell
查看>>
连续子数组的最大的和
查看>>
read
查看>>
IOS开发基础知识--碎片40
查看>>
android学习笔记45——android的数据存储和IO
查看>>
mysql 安装完以后没有mysql服务
查看>>
REP report开发技巧
查看>>
js-ES6学习笔记-编程风格(2)
查看>>
从相册中取图片
查看>>
hdu1874畅通工程再续
查看>>
无线网络不受到攻击与窃听的几个小诀窍
查看>>
JDK中的Timer和TimerTask详解
查看>>