Skip to content

fspv/leetcode-anki

Repository files navigation

build style tests types license

Leetcode Anki card generator

Summary

By running this script you'll be able to generate Anki cards with all the leetcode problems.

I personally use it to track my grinding progress.

ezgif-7-03b29041a91e

photo_2021-09-29_08-58-19 jpg 2 photo_2021-09-29_08-58-21 jpg 2 photo_2021-09-29_08-58-23 jpg 2

Prerequisites

  1. python3.8+ installed
  2. python virtualenv installed
  3. git cli installed
  4. GNU make installed (optional, can run the script directly)
  5. *nix operating system (Linux, MacOS, FreeBSD, ...). Should also work for Windows, but commands will be different. I'm not a Windows expert, so can't figure out how to make it work there, but contributions are welcome.

How to run

First download the source code

git clone https://github.com/prius/leetcode-anki.git
cd leetcode-anki

After that initialize and activate python virtualenv somewhere

Linux/MacOS

virtualenv -p python leetcode-anki
. leetcode-anki/bin/activate

Windows

python -m venv leetcode-anki
.\leetcode-anki\Scripts\activate.bat

Then initialize session id variable. You can get it directly from your browser (if you're using chrome, cookies can be found here chrome://settings/cookies/detail?site=leetcode.com)

Note, since 24.07.24 you need to manually set CSRF token as well. You can find it in the same place as session id.

Chrome example cookie

Linux/Macos

export LEETCODE_SESSION_ID="yyy"
export LEETCODE_CSRF_TOKEN="zzz"

Windows

set LEETCODE_SESSION_ID="yyy"
set LEETCODE_CSRF_TOKEN="zzz"

Then you can run the script

Classic Lightweight Cards

Run for Linux/MacOS

make generate

Or for Windows

pip install -r requirements.txt
python generate.py

Including your Last Submission Code

Example if code on the back card part

Run for Linux/MacOS

make generate-with-last-submissions

Or for Windows

pip install -r requirements.txt
python generate.py --problem-status AC --include-last-submission True

You'll get leetcode.apkg file, which you can import directly to your anki app.

About

Anki cards generator for Leetcode

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •