Skip to content

tabloomoo/LeetCode-Anki

 
 

Repository files navigation

中文版 | English

Introduction

When practicing on LeetCode, you often encounter problems similar to ones you've solved before, but forget the solution approach. Anki is a cross-platform memory tool based on the forgetting curve, supporting Mac, Linux, Windows, iOS, and Android platforms. While Anki is an excellent memory tool, it requires manual card creation, which is tedious and time-consuming.

Invest some time to automate or simplify a process to save more time in the future

This project aims to automatically fetch your accepted LeetCode problems and generate Anki decks to help you remember them.

The crawled data includes:

  1. Problem title, difficulty, and description.
  2. Official solutions (Premium solutions require a subscription to fetch).
  3. Your accepted submission code.

DEMO

Front Back
front back

Example Deck

Usage

First, clone the repository and install Python dependencies:

git clone https://github.com/tabloomoo/LeetCode-Anki.git
cd LeetCode-Anki
pip3 install -r requirements.txt

Run the crawler and output the Anki deck to ./data/LeetCode.apkg (as specified in project.conf):

python3 main.py

For LeetCode.cn support:

python3 main_cn.py

On the first run, you need to obtain cookies. Running main.py will open a Chrome window where you manually enter your username and password to log in once.

⚠️ Note:

  1. If you need to re-login via browser, simply delete the cookie.dat file in the directory.
  2. If the browser driver is outdated (currently V86.0), please download the Chrome Selenium driver and replace the old driver in the vendor directory.

Enjoy using Anki to review the problems you've solved!

Customization

If you don't like the default Anki card style, you can modify the following three parameters in project.conf to customize the generated Anki cards:

[DB]
path = ./data
debug = False

[Anki]
front = ./templates/front-side.html
back = ./templates/back-side.html
css = ./templates/style.css
output = ./data/LeetCode.apkg
  • front: The format of the card front side.
  • back: The format of the card back side.
  • css: The CSS style for the cards.

LICENSE

This project is licensed under the GPL V3 open source license.

Acknowledgements

This project is based on many excellent open source projects:

About

Beat LeetCode with the Power of Anki.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 75.8%
  • CSS 17.2%
  • HTML 7.0%