/** * Return an array of arrays of size *returnSize. * The sizes of the arrays are returned as *returnColumnSizes array. * Note: Both returned array and *columnSizes array must be malloced, assume caller calls free(). */ int** generate(int numRows, int* returnSize, int** returnColumnSizes){ *returnSize = numRows; int** res = (int**)malloc(sizeof(int*)*numRows);
classSolution: defgenerate(self, numRows: int) -> List[List[int]]: if numRows == 0: return [] res = [[1]] whilelen(res) < numRows: newRow = [a+b for a, b inzip([0]+res[-1], res[-1]+[0])] res.append(newRow) return res