标签:code nbsp col cto style row turn push back
1 class Solution 2 { 3 public: 4 vector<int> getRow(int k) 5 { 6 int n = k + 1; 7 vector<vector<int>> ans; 8 for(int i = 0;i < n;i ++) 9 { 10 ans.push_back(vector<int>()); 11 for(int j = 0;j <= i;j ++) 12 { 13 ans[i].push_back(1); 14 } 15 } 16 for(int i = 2;i < n;i ++) 17 { 18 for(int j = 1;j < i;j ++) 19 { 20 ans[i][j] = ans[i - 1][j - 1] + ans[i - 1][j]; 21 } 22 } 23 return ans[k]; 24 } 25 };
标签:code nbsp col cto style row turn push back
原文地址:https://www.cnblogs.com/yuhong1103/p/12614123.html