diff --git a/c/118-Pascals-triangle.c b/c/118-Pascals-triangle.c new file mode 100644 index 000000000..4ab56a62d --- /dev/null +++ b/c/118-Pascals-triangle.c @@ -0,0 +1,24 @@ +/* +Given an integer numRows, return the first numRows of Pascal's triangle. + +Space: O(n²) (n=numRows) +Time: O(n²) +*/ + +int** generate(int numRows, int* returnSize, int** returnColumnSizes){ + *returnSize = numRows; + (*returnColumnSizes) = malloc(sizeof(int*)*numRows); + int** ans = malloc(sizeof(int*)*numRows); + for (int i=0; i