题解 | #杨辉三角(二)#杨辉三角(1)改改就出来了
杨辉三角(二)
https://www.nowcoder.com/practice/486a9408fe2d4912843795c25d43acc2
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param num int整型
* @return int整型vector
*/
vector<int> getRow(int num) {
num+=1;
vector<vector<int>> res;
if (num >= 1)res.push_back({1});
if (num >= 2) {
for (int i = 1; i < num; i++) {
vector<int> tmp;
for (int j = 0; j <= i; j++)tmp.push_back(1);
for (int j = 0; j < i; j++)tmp[j] = res[i - 1][j - 1] + res[i - 1][j];
res.push_back(tmp);
}
}
return res.at(num-1);
}
};

