From 82ca460a9cc6c450e2cbdbfbef07d2d609d4ab96 Mon Sep 17 00:00:00 2001 From: Adhiraj Date: Wed, 5 Oct 2022 23:01:51 +0530 Subject: [PATCH] feat: add LeetCode problem 118 (#996) * added 118 to list * added 118.c --- leetcode/README.md | 1 + leetcode/src/118.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 leetcode/src/118.c diff --git a/leetcode/README.md b/leetcode/README.md index 0cd07e3d..cdb81b46 100644 --- a/leetcode/README.md +++ b/leetcode/README.md @@ -37,6 +37,7 @@ LeetCode |109|[Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) | [C](./src/109.c)|Medium| |110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree/) | [C](./src/110.c)|Easy| |112|[Path Sum](https://leetcode.com/problems/path-sum/) | [C](./src/112.c)|Easy| +|118|[Pascal's Triangle](https://leetcode.com/problems/pascals-triangle/) | [C](./src/118.c)|Easy| |121|[Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/) | [C](./src/121.c)|Easy| |125|[Valid Palindrome](https://leetcode.com/problems/valid-palindrome/) | [C](./src/125.c)|Easy| |136|[Single Number](https://leetcode.com/problems/single-number/) | [C](./src/136.c)|Easy| diff --git a/leetcode/src/118.c b/leetcode/src/118.c new file mode 100644 index 00000000..a926efdc --- /dev/null +++ b/leetcode/src/118.c @@ -0,0 +1,26 @@ +/** + * 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 **ans = (int**)malloc(numRows*sizeof(int*)); + *returnColumnSizes = (int*)malloc(numRows*sizeof(int)); + + for (int i=0; i