Given numRows, generate the first numRows of Pascal's triangle.

For example, given numRows = 5,
Return

[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]

帕斯卡三角,很简单的问题,见代码:

 class Solution {
public:
vector<vector<int>> generate(int numRows) {
vector<vector<int>> ret;
vector<int> tmpVec;
ret.clear();
tmpVec.clear();
for(int i = ; i < numRows; ++i){
if(i == ){
tmpVec.push_back();
}else{
for(int j = ; j <= i; ++j){
if(j == ) tmpVec.push_back();
else if(j == i) tmpVec.push_back();
else tmpVec.push_back(ret[i - ][j - ] + ret[i - ][j]);
}
}
ret.push_back(tmpVec);
tmpVec.clear();
}
return ret;
}
};

最新文章

  1. 【30集iCore3_ADP出厂源代码(ARM部分)讲解视频】30-3 底层驱动之LED_蜂鸣器
  2. Ubuntu 14.04 Trusty安装java环境
  3. 中国电信大亚DP607光猫破解,设置路由,wifi!关闭远程管理,改连接限制,SN码查询!
  4. linux_过程问题记录
  5. TAG的用法和用途[转]
  6. 变量-if else while-运算符
  7. php面向对象4
  8. NFS+sersync+Keepalived高可用方案
  9. Vue2 Virtual DOM
  10. 插件使用一颜色选择器---cxColor
  11. Linux find 命令参数大全及示例
  12. Golang channel 用法简介
  13. 开始试用Dynamics 365
  14. laravel数据迁移
  15. python3【基础】-文件操作
  16. 安卓中AsyncTask的基本使用
  17. Hadoop2.X分布式集群部署
  18. HDU-3592 World Exhibition
  19. 乘法逆元__C++
  20. BZOJ3224普通平衡树

热门文章

  1. (3.8)常用知识-临时表、表变量、CTE的对比
  2. 使用Free命令查看Linux服务器内存使用状况(-/+ buffers/cache详解)
  3. 如何根据一些参数,自动生成一个简单的maven工程,然后导入Eclipse直接使用?(maven命令)
  4. 第六课 GDB调试 (上)
  5. idea 快键件大全
  6. ZOJ 3261 Connections in Galaxy War (逆向+带权并查集)
  7. CSS3鼠标悬停边框线条动画按钮
  8. 0927-转载:SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释
  9. iOS动画进阶 - 手摸手教你写 Slack 的 Loading 动画
  10. maven说明