This repo archives all solutions for all LeetCode problems in all available languages. (continous updating...)
Note
The question list has to be put in an separate index.md file. It is impossible to list all questions in the readme.md since github only display first 500KB of the readme file :(
-
Clone the repository:
git clone https://github.com/yourusername/LeetCode-Solutions.git cd LeetCode-Solutions
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.env
file in the root directory with the following content:LEETCODE_USERNAME=your_github_username LEETCODE_PASSWORD=your_github_password OPENAI_API_KEY=your_openai_api_key
Important
Solver uses OpenAI's GPT-4o model to generate solutions so you need to set up your OpenAI API key in the .env
file. Alternatively, you can modify the code to use any model you want.
Important
Both Solver and Retriver use the github login method to login to LeetCode so you need to set up your github login credentials in the .env
file.
Solver is an automated script designed to solve LeetCode problems using AI-powered code generation. It interacts with the LeetCode platform to fetch problems, generate solutions, submit them, and handle debugging if necessary.
- Use
python solver.py
to run the solver.
The solver will automatically:
- Log in to LeetCode
- Find the next unsolved problem
- Generate a solution using GPT-4
- Test the solution
- Submit the solution if tests pass
- Debug and retry if the solution fails
Retriver is an automated script designed to fetch solved LeetCode problems and solutions from the LeetCode platform, then archives the problem details and solutions.
- Use
python retriver.py
to run the retriver.
The retriver will:
- Log in to LeetCode
- Fetch all solved problems
- Archive the problem details and solutions
Contributions are welcome!
This tool is for educational purposes only. Please use it responsibly and in accordance with LeetCode's terms of service.