TheAlgorithms-C/leetcode
Rishav Kumar 9997c8bdf0
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 <m18824909883@163.com>

* updating DIRECTORY.md

---------

Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
Co-authored-by: Stepfen Shawn <m18824909883@163.com>
2023-03-17 12:01:44 -06:00
..
src feat: remove nth node from end of list LeetCode (#1222) 2023-03-03 09:12:04 -06:00
DIRECTORY.md fix: memory allocation method (#1220) 2023-03-17 12:01:44 -06:00
README.md docs: update the LeetCode contributing guide (#1225) 2023-02-28 20:28:06 -06:00

README.md

📚 Contributing 📚

We're glad you're interested in adding C LeetCode solutions to the repository.
Here we'll be explaining how to contribute to LeetCode solutions properly.

💻 Cloning/setting up the project 💻

First off, you'll need to fork the repository here.
Then, you'll need to clone the repository to your local machine.

git clone https://github.com/your-username/C.git

After that, you'll need to create a new branch for your solution.

git checkout -b solution/your-solution-name

📝 Adding a new solution 📝

All LeetCode problems can be found here.
If you have a solution to any of these problems (which are not being repeated), that's great! Here are the steps:

  1. Add a new file in leetcode/src with the number of the problem.
    • For example: if the problem's number is 98, the filename should be 98.c.
  2. Provide a small description of the solution at the top of the file. A function should go below that. For example:
/**
 * 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().
 */
  1. Do not provide a main function. Use the required standalone functions instead.
  2. Doxygen documentation isn't used in LeetCode solutions. Simple/small documentation or comments should be fine.
  3. Don't include libraries/headers such as stdio.h. Your file should be the solution to the problem only.

Note There was a requirement to update the leetcode/DIRECTORY.md file with details of the solved problem. It's not required anymore. The information about the problem is fetched automatically throughout the LeetCode API.

📦 Committing your changes 📦

Once you're done with adding a new LeetCode solution, it's time we make a pull request.

  1. First, stage your changes.
git add leetcode/src/98.c # Use `git add .` to stage all changes.
  1. Then, commit your changes.
git commit -m "feat: add LeetCode problem 98" -m "Commit description" # Optional
  1. Finally, push your changes to your forked repository.
git push origin solution/your-solution-name:solution/your-solution-name
  1. You're done now! You just have to make a pull request. 🎉

If you need any help, don't hesitate to ask and join our Discord server! 🙂