From 9997c8bdf0aac59281dd3105f898ae325334c94f Mon Sep 17 00:00:00 2001 From: Rishav Kumar <85122792+i-m-afk@users.noreply.github.com> Date: Fri, 17 Mar 2023 23:31:44 +0530 Subject: [PATCH] fix: memory allocation method (#1220) * Fix : memory allocation method "new" is not used in C , because of that the compiler was giving compilation error. Instead malloc was used for memory allocation. * updating DIRECTORY.md * Update data_structures/graphs/kruskal.c Co-authored-by: Stepfen Shawn * updating DIRECTORY.md --------- Co-authored-by: github-actions[bot] Co-authored-by: Stepfen Shawn --- data_structures/graphs/kruskal.c | 4 ++-- leetcode/DIRECTORY.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data_structures/graphs/kruskal.c b/data_structures/graphs/kruskal.c index 49d1c54c..0f72c6b5 100644 --- a/data_structures/graphs/kruskal.c +++ b/data_structures/graphs/kruskal.c @@ -27,11 +27,11 @@ struct Graph // Creates a graph with V vertices and E edges struct Graph *createGraph(int V, int E) { - struct Graph *graph = new Graph(); + struct Graph* graph = (struct Graph*)(malloc(sizeof(struct Graph))); graph->V = V; graph->E = E; - graph->edge = new Edge[E]; + graph->edge = (struct Edge*)malloc(sizeof(struct Edge) * E); return graph; } diff --git a/leetcode/DIRECTORY.md b/leetcode/DIRECTORY.md index 1ae9af3a..4807b447 100644 --- a/leetcode/DIRECTORY.md +++ b/leetcode/DIRECTORY.md @@ -27,7 +27,7 @@ | 24 | [Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs) | [C](./src/24.c) | Medium | | 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array) | [C](./src/26.c) | Easy | | 27 | [Remove Element](https://leetcode.com/problems/remove-element) | [C](./src/27.c) | Easy | -| 28 | [Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string) | [C](./src/28.c) | Medium | +| 28 | [Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string) | [C](./src/28.c) | Easy | | 29 | [Divide Two Integers](https://leetcode.com/problems/divide-two-integers) | [C](./src/29.c) | Medium | | 32 | [Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses) | [C](./src/32.c) | Hard | | 35 | [Search Insert Position](https://leetcode.com/problems/search-insert-position) | [C](./src/35.c) | Easy |