Exact same as I.

 1 class Solution {
 2 public:
 3     vector<int> getRow(int rowIndex) {
 4         if (rowIndex < 0) return vector<int> ();
 5         vector<int> result(1, 1);
 6         for (int i = 1; i <= rowIndex; i++) {
 7             for (int j = result.size()-1; j > 0; j--) {
 8                 result[j] += result[j-1];
 9             }
10             result.push_back(1);
11         }
12         return result;
13     }
14 };

 

posted on 2015-03-21 17:19  keepshuatishuati  阅读(99)  评论(0编辑  收藏  举报