Given an integer numRows, return the first numRows of Pascal's triangle.

In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:

&nbsp;
Example 1:
Input: numRows = 5
Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
Example 2:
Input: numRows = 1
Output: [[1]]

&nbsp;
Constraints:


	1 &lt;= numRows &lt;= 30


class Solution:
    def generate(self, numRows: int) -> List[List[int]]:
        if numRows == 1:
            return [[1]]
        if numRows == 2:
            return [[1], [1, 1]]
        ans = [[1], [1, 1]]
        for x in range(1, numRows - 1):
            tmp = [1]
            for k in range(len(ans[x]) - 1):
                tmp.append(ans[x][k] + ans[x][k + 1])
            tmp.append(1)
            ans.append(tmp)
        return ans
class Solution {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> list = new LinkedList();
        list.add(Arrays.asList(1));
        if(numRows == 1) return list;
        list.add(Arrays.asList(1,1));
        
        for(int i = 1; i < numRows - 1; i++) {
            List<Integer> temp = list.get(i);
            List<Integer> temp2 = new ArrayList();
            temp2.add(1);
            for(int j = 0; j < temp.size() - 1; j++) {
                temp2.add(temp.get(j) + temp.get(j+1));
            }
            temp2.add(1);
            list.add(temp2);
        }
        
        return list;
    }
}
class Solution {
public:
    vector<vector<int>> generate(int numRows) {
        vector<vector<int>> ans(numRows, vector<int>());
        for(int i = 0; i<numRows; i++){
            for(int j = 0; j <= i; j++){
                if(j == 0 || j == i){
                    ans[i].push_back(1);
                }else{
                    ans[i].push_back(ans[i-1][j-1] + ans[i-1][j]);
                }
            }
        }
        return ans;
    }
};
var generate = function(numRows) {
    let ans = new Array(numRows)
    for (let i = 0; i < numRows; i++) {
        let row = new Uint32Array(i+1).fill(1),
            mid = i >> 1
        for (let j = 1; j <= mid; j++) {
            let val = ans[i-1][j-1] + ans[i-1][j]
            row[j] = val, row[row.length-j-1] = val
        }
        ans[i] = row
    }
    return ans
};
Pascal's Triangle