标签:
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 };
LeetCode - Refresh - Pascal's Triangle II
标签:
原文地址:http://www.cnblogs.com/shuashuashua/p/4355881.html