{"id":15283839,"url":"https://github.com/johnsutor/leetcode-study-tool","last_synced_at":"2025-10-30T01:41:01.071Z","repository":{"id":187959359,"uuid":"677767766","full_name":"johnsutor/leetcode-study-tool","owner":"johnsutor","description":"This package lets you get grokking as quickly as possible with Leetcode.","archived":false,"fork":false,"pushed_at":"2025-03-01T22:35:49.000Z","size":15997,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T23:09:16.587Z","etag":null,"topics":["anki","anki-flashcards","excel-export","grokking","leetcode","leetcode-python","neetcode","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnsutor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-12T15:17:42.000Z","updated_at":"2025-03-01T22:34:36.000Z","dependencies_parsed_at":"2025-01-04T03:39:03.886Z","dependency_job_id":null,"html_url":"https://github.com/johnsutor/leetcode-study-tool","commit_stats":null,"previous_names":["johnsutor/leetcode-study-tool"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsutor%2Fleetcode-study-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsutor%2Fleetcode-study-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsutor%2Fleetcode-study-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsutor%2Fleetcode-study-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnsutor","download_url":"https://codeload.github.com/johnsutor/leetcode-study-tool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643004,"owners_count":21138355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anki","anki-flashcards","excel-export","grokking","leetcode","leetcode-python","neetcode","python"],"created_at":"2024-09-30T14:47:51.352Z","updated_at":"2025-10-30T01:40:56.035Z","avatar_url":"https://github.com/johnsutor.png","language":"Python","readme":"# 💻 Leetcode Study Tool\n![Tests Status](https://github.com/johnsutor/leetcode-study-tool/workflows/Tests/badge.svg)\n![Style Status](https://github.com/johnsutor/leetcode-study-tool/workflows/Style/badge.svg)\n[![Python Versions](https://img.shields.io/pypi/pyversions/leetcode-study-tool)](https://pypi.org/project/leetcode-study-tool/)\n[![PyPi](https://img.shields.io/pypi/v/leetcode-study-tool)](https://pypi.org/project/leetcode-study-tool/)\n![contributions welcome](https://img.shields.io/badge/contributions-welcome-blue.svg?style=flat)\n\n![Leetcode Study Tool Diagram](https://github.com/johnsutor/leetcode-study-tool/raw/main/static/leetcode_study_tool_diagram.png)\n\nThis package lets you get grokking as quickly as possible with Leetcode. It provides a command-line tool for interracting with Leetcode to create either an Excel file or Anki flashcards for study. Currently, this tool supports taking in a list of leetcode question slugs or URLs or popular study sets (including the [Blind 75](https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-75-LeetCode-Questions-to-Save-Your-Time-OaM1orEU), [Grind 75](https://www.techinterviewhandbook.org/grind75), and [Neetcode 150](https://neetcode.io/practice)). \n\n## 🤔 Why? \nThis package was created as an opinionated alternative to other existing packages (as listed at the bottom of this README). \n\n## 📥 Installation\n```shell\n$ pip install leetcode-study-tool\n```\n\n## 💻 Usage \n```shell\nusage: leetcode-study-tool [-h] (--url URL | --file FILE | --preset {blind_75,grind_75,grind_169,neetcode_150,neetcode_250,neetcode_all}) [--format {anki,excel}]\n                           [--template TEMPLATE] [--csrf CSRF] [--output OUTPUT] [--language LANGUAGE] [--include-code]\n\nGenerates problems from LeetCode questions in a desired format.\n\noptions:\n  -h, --help            show this help message and exit\n  --url URL, -u URL     The URL(s) or slug(s) of the LeetCode question(s) to generate problem(s) for. (default: None)\n  --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)\n  --preset {blind_75,grind_75,grind_169,neetcode_150,neetcode_250,neetcode_all}, -p {blind_75,grind_75,grind_169,neetcode_150,neetcode_250,neetcode_all}\n                        The preset to use to generate problem(s) for. (default: None)\n  --format {anki,excel}, -F {anki,excel}\n                        The format to save the Leetcode problem(s) in. (default: anki)\n  --template TEMPLATE, -t TEMPLATE\n                        Path to a custom Jinja template file for rendering problems. (default: None)\n  --csrf CSRF, -c CSRF  The CSRF token to use for LeetCode authentication. (default: None)\n  --output OUTPUT, -o OUTPUT\n                        The output file to write the problem(s) to. (default: output.txt)\n  --language LANGUAGE, -l LANGUAGE\n                        The language to generate problem(s) for. (default: None)\n  --include-code, -ic   Include solution code from NeetCode GitHub repository using the specified language. (default: False)\n```\n\n## 💡 Example \nIn the simplest case, if you want to [Grok](https://www.reddit.com/r/leetcode/comments/t5xqb6/how_to_use_grokking/) the most commonly asked questions, you should generate from a preset. For example, generating Anki cards from the [Grind 75](https://www.techinterviewhandbook.org/grind75) is as simple as \n```shell\n$ leetcode-study-tool -p grind_75\n```\nPerhaps, 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 \n```shell\n$ leetcode-study-tool -f questions.txt \n```\nwhich 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*.\n\n![anki demo](static/anki-demo.gif)\n\n### Including Solution Code\n\nYou can include solution code from the NeetCode GitHub repository by using the `--include-code` flag along with specifying a programming language:\n\n```shell\n$ leetcode-study-tool -p grind_75 --language python --include-code\n```\n\nThis will fetch solution code in the specified language (when available) and include it in your Anki cards or Excel output.\n\nSupported languages include: c, cpp, csharp, dart, go, java, javascript, kotlin, python, ruby, rust, scala, swift, and typescript.\n\n## 📒 Anki\nWhen generating an Anki output, the resulting \"cards\" are saved as a `.txt` file. These cards include three fields:\n1. The front of the study card, containing the question ID, Title, URL, and problem description \n2. The publicly available solutions (and NeetCode solution or code, if available)\n3. The tags associated with the problem (i.e., if the problem involves a hash map, arrays, etc...)\n\n## 📊 Excel\nWhen generating an Excel output, the resulting questions are saved in an `.xlsx` file. Each problem includes the following fields:\n1. ID of the leetcode question\n2. Title of the leetcode question\n3. URL of the leetcode question\n4. Last date that this question was attempted by the user (please note that this is not pulled from your leetcode profile, but left for you to update as you progress in solving leetcode questions)\n5. The tags associated with the problem (i.e., if the problem involves a hash map, arrays, etc...)\n6. Neetcode video link (if it exists)\n7. Solution links for the problem (if they are reachable)\n8. Companies that have asked this question recently in interviews (if they are reachable)\n\n## Custom Templates\n\nLeetCode Study Tool supports custom Jinja2 templates for generating Anki cards or other outputs. You can specify your own template file using the `--template` flag:\n\n```bash\nleetcode-study-tool --url \"https://leetcode.com/problems/two-sum/\" --template \"path/to/my_template.jinja\"\n```\n\n### Template Variables\n\nWhen creating your custom template, the following variables are available:\n\n| Variable | Description |\n|----------|-------------|\n| `url` | The URL to the LeetCode problem |\n| `slug` | The problem slug |\n| `data` | Object containing all problem data |\n| `data.id` | Problem ID |\n| `data.title` | Problem title |\n| `data.content` | Problem description (HTML) |\n| `data.difficulty` | Problem difficulty (Easy, Medium, Hard) |\n| `data.tags` | List of topic tags for the problem |\n| `data.companies` | List of companies that ask this problem |\n| `data.solutions` | List of available solutions on LeetCode |\n| `data.neetcode_solution` | NeetCode solution code (if --include-code is used) |\n| `data.language` | Language of the solution code |\n| `neetcode` | NeetCode video information (when available) |\n\n### Solution Code Example\n\nHere's an example template that highlights the solution code:\n\n```jinja\n\u003ch1\u003e{{ data.id }}. {{ data.title }} ({{ data.difficulty }})\u003c/h1\u003e\n\n\u003cdiv class=\"content\"\u003e\n  {{ data.content }}\n\u003c/div\u003e\n\n\u003cdiv class=\"tags\"\u003e\n  {% for tag in data.tags %}\n    \u003cspan class=\"tag\"\u003e{{ tag.name }}\u003c/span\u003e\n  {% endfor %}\n\u003c/div\u003e\n\n;\n\n{% if data.neetcode_solution %}\n\u003ch3\u003eSolution Code ({{ data.language }})\u003c/h3\u003e\n\u003cpre\u003e\u003ccode\u003e\n{{ data.neetcode_solution }}\n\u003c/code\u003e\u003c/pre\u003e\n{% endif %}\n\n{% if data.solutions %}\n\u003cdiv class=\"community-solutions\"\u003e\n  \u003ch3\u003eCommunity Solutions:\u003c/h3\u003e\n  \u003cul\u003e\n    {% for solution in data.solutions[:3] %}\n      \u003cli\u003e\u003ca href=\"{{ solution_url(slug, solution.id) }}\"\u003eSolution {{ loop.index }}\u003c/a\u003e\u003c/li\u003e\n    {% endfor %}\n  \u003c/ul\u003e\n\u003c/div\u003e\n{% endif %}\n\n;\n\n{{ data.tags|map(attribute='slug')|join(' ') }}\n```\n\n## 🛣 Roadmap \n- [X] Use TQDM to show card generation progress\n- [X] Add support for exporting to an excel sheet\n- [X] Add support for showing neetcode solutions on the back of the card as a \n- [X] Add support for getting the difficulty of questions \n- [X] Add support for Jinja templating formatters \n- [X] Add support for including NeetCode solution code\n- [ ] Add NeetCode shorts \n- [ ] Add support for fetching premium questions via authentification\n- [ ] Add support for importing cards into Quizlet\n- [ ] Add support for fetching questions by topic or tag \nlink\n- [ ] Reach 90% test coverage\n\n## 🔎 Other Usefull Stuff\n- [Remember anything with Anki](https://foggymountainpass.com/anki-essentials/)\n- [Leetcode Anki Card Generator](https://github.com/fspv/leetcode-anki)\n- [Leetcode API](https://github.com/fspv/python-leetcode)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsutor%2Fleetcode-study-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnsutor%2Fleetcode-study-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsutor%2Fleetcode-study-tool/lists"}