利用对称性简化:

//
// Created by jt on 2020/9/2.
//
#include <vector>
using namespace std;

class Solution {
public:
    /**
     *
     * @param numRows int整型
     * @return int整型vector<vector<>>
     */
    vector<vector<int> > generate(int numRows) {
        // write code here
        vector<vector<int> > res;
        for (int i = 1; i <= numRows; ++i) {
            vector<int> vec(i, 1);
            for (int j = (i-1) / 2; j > 0; --j) {
                vec[j] = res[i-2][j] + res[i-2][j-1];
                vec[(i-1)-j] = vec[j];
            }
            res.push_back(vec);
        }
        return res;
    }
};