Skip to main content

A tool for studying Leetcode with Python

Project description

Leetcode Study Tool

Tests Status Style Status Python Versions PyPi contributions welcome

This package lets you get grokking as quickly as possible with Leetcode. It provides a command-line tool for interracting with Leetcode to create flashcards for study, which can then be imported into Anki. Currently, this tool supports taking in a list of or popular study sets (including the Blind 75, Grind 75, and Neetcode 150) and outputting problems in a format that can be imported to Anki. These cards include three fields:

  1. The front of the study card, containing the question ID, Title, URL, and problem description
  2. The publicly available solutions (and NeetCode solution, if available)
  3. The tags associated with the problem (i.e., if the problem involves a hash map, arrays, etc...)

Why?

This package was created as an opinionated alternative to other existing packages (as listed at the bottom of this README).

Installation

$ pip install leetcode-study-tool

Usage

usage: leetcode-study-tool [-h]
                           (--url URL | --file FILE | --preset {blind_75,grind_75,grind_169,neetcode_150,neetcode_all})
                           [--format {anki,excel}] [--csrf CSRF] [--output OUTPUT]
                           [--language LANGUAGE]

Generates problems from LeetCode questions in a desired format.

options:
  -h, --help            show this help message and exit
  --url URL, -u URL     The URL(s) or slug(s) of the LeetCode question(s) to generate
                        problem(s) for. (default: None)
  --file FILE, -f FILE  The file containing the URL(s) or slug(s) of the LeetCode question(s)
                        to generate problem(s) for. (default: None)
  --preset {blind_75,grind_75,grind_169,neetcode_150,neetcode_all}, -p {blind_75,grind_75,grind_169,neetcode_150,neetcode_all}
                        The preset to use to generate problem(s) for. (default: None)
  --format {anki,excel}, -F {anki,excel}
                        The format to save the Leetcode problem(s) in. (default: anki)
  --csrf CSRF, -c CSRF  The CSRF token to use for LeetCode authentication. (default: None)
  --output OUTPUT, -o OUTPUT
                        The output file to write the problem(s) to. (default: output.txt)
  --language LANGUAGE, -l LANGUAGE
                        The language to generate problem(s) for. (default: None)

Example

In the simplest case, if you want to Grok the most commonly asked questions, you should generate from a preset. For example, generating Anki cards from the Grind 75 is as simple as

$ leetcode-study-tool -p grind_75

Perhaps, instead, you'd prefer to import questions that you've already worked on. In a directory with a file named questions.txt, where each line is either a Leetcode problem URL or slug (or a combination of both), we can run the command

$ leetcode-study-tool -f questions.txt 

which will generate the file output.txt. We can then open Anki to import these problems as demonstrated below, ensuring to select semicolon as a field separator.

anki demo

Roadmap

  • Add support for getting the difficulty of questions
  • Add support for fetching premium questions via authentification
  • Add support for importing cards into Quizlet
  • Add support for fetching questions by topic or tag
  • Add support for exporting to an excel sheet
  • Add support for showing neetcode solutions on the back of the card as a link
  • Add support for determining which fields to show on the card
  • Use TQDM to show card generation progress
  • Allow for the definition of custom formatters and outputs
  • Reach 90% test coverage

Other Usefull Stuff

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

leetcode-study-tool-1.2.0.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

leetcode_study_tool-1.2.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file leetcode-study-tool-1.2.0.tar.gz.

File metadata

  • Download URL: leetcode-study-tool-1.2.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for leetcode-study-tool-1.2.0.tar.gz
Algorithm Hash digest
SHA256 b447c5c417c9353dc4b982e7ae35c0198e805b1e3cb6437f02f9fbfd78988735
MD5 ba4a09cfb761c65147df0be5e6195cad
BLAKE2b-256 28dd018a189756db36bed11764a334075bd66f3901534edd48a30a43cd2a3f40

See more details on using hashes here.

File details

Details for the file leetcode_study_tool-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for leetcode_study_tool-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe2115fa4e69fe4095c5e77cc6356939b4ca26f317e03228794305cbe6d45c8d
MD5 980bf42dcf4f2e70206aef1fcb1bbf27
BLAKE2b-256 fd663e5d24308166387bcfdda44c3b4dfa6f711ac09233bc7084b2c8fe9f86fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page