- First steps:
- Clone this repository and create a new branch with convenient names like the followings:
- add-problem-name
- add-problem-name-approach-2
- fix-problem-name-python-sol
- fix-problem-name-readme
- When you are done with your code open a new PR to the master and describe in your PR why you creating this PR:
- Adding Problem Name (as a link to the problem) solution in [Chosen language].
- Clone this repository and create a new branch with convenient names like the followings:
- Add a new solution for an existing problem:
-
You need to update the existing problem
README.md
file with your solution. -
The file will be organized in this hierarchy:
- Approach 1
- Approach 2
- ...etc
-
So check what is the level of your solution and add it:
- Approach 2:
your solution
- Approach 2:
-
If you add a new solution without explaining it do your best at least to add the time & space complexity for it or pseudocode.
-
If you can not fit the previous step you can ignore the hierarchy of the
Approaches
and add your solution this way:- Another implementation in
the language you writing in
. (Make sure it is a URL to the solution.[js,java] file)
- Another implementation in
-
Let's say if your new solution is in a language already exist in the repo like
Solution.py
you can edit this file by adding another function lets say the solution in function calledsum2numbers(x,y)
add new functionsum2numbers_2(X,Y)
, I would prefer doing it this way otherwise you can create a new file calledSolution2.py
. -
If your solution the same idea as
Approach 1
for example but in different language you just need to add as mentioned above and update the problemREADME
file with a link to your code:- Solution in java as url of course to Solution.java.
-
- Add a new solution for a new problem:
-
So, let's say the problem belongs to the
30-Day LeetCoding Challenge
so go to it is a directory and create a new folder with the problem namenew-problem
add a URL to that directory in theREADME.md
if it isweek
not there add it as well in the same way as the existing ones. -
Then, under the
new-problem
directory createREADME.md
file andSolution.[chosen-lang]
. -
Write the
README.md
file in the same way as existing one's header with the problem name as URL to the problem location on Leetcode, then addApproach 1
title then add your solution follow the steps as in the above section (Add a new solution for an existing problem). -
What if it is a random problem from Leetcode problem, create a new directory for this new problem in the main folder
leetcode-problems/the-new-random-problem
and add it in the mainREADME.md
as well as URL to this new directory for sure, the structure of thethe-new-random-problem
must be the same as above.
-
Feel free to open issues with any required changes