LeetCode(Oct 28 '12):Pascal's Triangle
来源:互联网 发布:php 考试开源系统源码 编辑:程序博客网 时间:2024/06/03 23:40
水题一枚...练练手...
原题地址戳此:
http://leetcode.com/onlinejudge#question_118
要求如下:
代码如下:
class Solution {public: vector<vector<int> > generate(int numRows) {vector<vector<int> > result;if(numRows<1){return result;}vector<int> first;first.push_back(1);result.push_back(first);for(int i=2;i<=numRows;i++){ vector<int> row;for(int n=1;n<=i;n++){if(n==1||n==i){row.push_back(1);}else{row.push_back(result[i-1-1][n-1-1]+result[i-1-1][n-1]);}}result.push_back(row);}return result; }};
- LeetCode(Oct 28 '12):Pascal's Triangle
- LeetCode(Oct 29 '12):Pascal's Triangle II
- 【Leetcode】Pascal's Triangle (Pascal)
- LeetCode Pascal's Triangle
- [Leetcode] Pascal's Triangle
- LeetCode: Pascal's Triangle
- [LeetCode] Pascal's Triangle
- 【leetcode】Pascal's Triangle
- LeetCode - Pascal's Triangle
- [LeetCode]Pascal's Triangle
- Leetcode: Pascal's Triangle
- Pascal's Triangle --Leetcode
- LeetCode-Pascal's Triangle
- [leetcode] Pascal's Triangle
- LeetCode - Pascal's Triangle
- 【leetcode】Pascal's Triangle
- LeetCode | Pascal's Triangle
- Pascal's Triangle -leetcode
- Linux2.6 内核的 Initrd 机制解析
- int,int32_t,int64_t
- httpClient下载图片
- 存储过程实现登录验证
- jsp下显示中文文件名的图片解决办法
- LeetCode(Oct 28 '12):Pascal's Triangle
- 获取IOS设备的系统版本,硬件名称,mac地址
- 校园网iNode下配置RHEL6网络
- 用于构建强大云应用程序的组件块
- fzu1649(大数素数判定)
- Andorid APK反逆向解决方案:梆梆加固原理探寻
- VM下安装Centos6.4发ping外网时出现"network is unreachable"解决
- 接口与抽象类区别
- 【转】随机算法全面总结