qingcheng奕  

2013年11月15日

摘要: http://oj.leetcode.com/problems/pascals-triangle-ii/杨辉三角2,比杨辉三角要求的空间上限制Could you optimize your algorithm to use onlyO(k) extra space?其实计算当前行,也只用到前一行了。再前面的没有用。class Solution {public: vector getRow(int rowIndex) { // IMPORTANT: Please reset any member data you declared, as // the same... 阅读全文
posted @ 2013-11-15 14:51 qingcheng奕 阅读(142) 评论(0) 推荐(0) 编辑
 
摘要: http://oj.leetcode.com/problems/pascals-triangle/杨辉三角先分析数据,找出规律ans[row][col] = ans[row-1][col-1]+ans[row-1][col]#include #include #include using namespace std;class Solution {public: vector > generate(int numRows) { // IMPORTANT: Please reset any member data you declared, as // the ... 阅读全文
posted @ 2013-11-15 14:01 qingcheng奕 阅读(155) 评论(0) 推荐(0) 编辑