就一句话,注意下表
class Solution {public: vector<vector<int>> generate(int numRows) { vector<vector<int>>ve; vector<int>vec; if(numRows == 0) return ve; vec.push_back(1); ve.push_back(vec); if(numRows == 1) return ve; vec.push_back(1); ve.push_back(vec); for(int i = 3; i <= numRows; ++ i){ vec.clear(); vec.push_back(1); for(int j = 2; j <= i - 1; ++ j){ vec.push_back(ve[i - 1 - 1][j - 1 - 1] + ve[i - 1 - 1][j - 1]); } vec.push_back(1); ve.push_back(vec); } return ve; }};新闻热点
疑难解答