This repository contains solutions to LeetCode problems, categorized by difficulty level (Easy, Medium, Hard). Each problem has its own dedicated directory with a README.md
file providing problem descriptions and explanations, as well as solution files in various programming languages.
To access the solutions, navigate to the desired difficulty level directory and then to the specific problem directory. Inside each problem directory, you will find a README.md
file with the problem description and explanations, as well as solution files in various programming languages.
The repository is organized as follows:
LeetCode/
├── Easy/
│ ├── Problem1/
│ │ ├── README
│ │ ├── solution.java
│ │ ├── solution.cpp
│ │ ├── Approach1/
│ │ │ ├── README
│ │ │ ├── solution.js
│ │ │ └── ...
│ │ └── ...
│ ├── Problem2/
│ │ ├── README
│ │ ├── solution.java
│ │ ├── solution.cpp
│ │ ├── Approach1/
│ │ │ ├── README
│ │ │ ├── solution.js
│ │ │ └── ...
│ │ └── ...
│ └── ...
├── Medium/
│ ├── Problem1/
│ │ ├── README
│ │ ├── solution.java
│ │ ├── solution.cpp
│ │ ├── Approach 1/
│ │ │ ├── README
│ │ │ ├── solution.js
│ │ │ └── ...
│ │ └── ...
│ ├── Problem2/
│ │ ├── README
│ │ ├── solution.java
│ │ ├── solution.cpp
│ │ └── ...
│ └── ...
├── Hard/
│ ├── Problem1/
│ │ ├── README
│ │ ├── solution.java
│ │ ├── solution.cpp
│ │ ├── Approach1/
│ │ │ ├── README
│ │ │ ├── solution.js
│ │ │ └── ...
│ │ └── ...
│ ├── Problem2/
│ │ ├── README
│ │ ├── solution.java
│ │ ├── solution.cpp
│ │ └── ...
│ └── ...
For problems with multiple solution, you can add your solution like this:
// Solution #1
class Solution {
/*
* Code for Solution #1
*/
}
// Solution #2
class Solution {
/*
* Code for Solution #2
*/
}
If you want to add a new approach and want to explain your approach you can add your solution by following this directory structure: (see example)
LeetCode/
├── [DIFFICULTY]/
│ ├── [PROBLEM]/
│ │ ├── README
│ │ ├── solution.java
│ │ ├── solution.cpp
│ │ ├── [MY APPROACH]/
│ │ │ ├── README
│ │ │ ├── solution.java
│ │ │ └── ...
│ │ └── ...
Contributions are welcome! If you'd like to add your own solutions or improve existing ones, please follow these guidelines:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with clear commit messages.
- Push your changes to your fork.
- Submit a pull request to this repository.
Please ensure your code follows good coding practices, is well-documented, and includes test cases where applicable. see the CONTRIBUTING file for details.
This project is licensed under the MIT License - see the LICENSE file for details.