{"id":43391987,"url":"https://github.com/wislertt/leetcode-py","last_synced_at":"2026-04-01T19:22:32.939Z","repository":{"id":312087552,"uuid":"1046223472","full_name":"wislertt/leetcode-py","owner":"wislertt","description":"Python LeetCode practice environment with automated problem generation, data structure visualizations, and comprehensive testing. Includes all Grind 75, partial Blind, Neetcode and Algomaster problems with enhanced TreeNode/ListNode helpers, CI/CD pipeline, and LLM-assisted problem creation.","archived":false,"fork":false,"pushed_at":"2026-03-20T04:29:38.000Z","size":2918,"stargazers_count":108,"open_issues_count":2,"forks_count":13,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-20T20:57:01.596Z","etag":null,"topics":["algomaster","algorithms","blind","coding-interview","competitive-programming","data-structures","good-first-issue","grind","interview","leetcode","neetcode","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/leetcode-py-sdk/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wislertt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"wislertt"}},"created_at":"2025-08-28T11:21:53.000Z","updated_at":"2026-03-20T04:28:56.000Z","dependencies_parsed_at":"2025-10-10T20:37:39.875Z","dependency_job_id":null,"html_url":"https://github.com/wislertt/leetcode-py","commit_stats":null,"previous_names":["wisarootl/leetcode-py","wislertt/leetcode-py"],"tags_count":112,"template":false,"template_full_name":null,"purl":"pkg:github/wislertt/leetcode-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wislertt%2Fleetcode-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wislertt%2Fleetcode-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wislertt%2Fleetcode-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wislertt%2Fleetcode-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wislertt","download_url":"https://codeload.github.com/wislertt/leetcode-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wislertt%2Fleetcode-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["algomaster","algorithms","blind","coding-interview","competitive-programming","data-structures","good-first-issue","grind","interview","leetcode","neetcode","python"],"created_at":"2026-02-02T13:28:48.021Z","updated_at":"2026-04-01T19:22:32.932Z","avatar_url":"https://github.com/wislertt.png","language":"Python","funding_links":["https://github.com/sponsors/wislertt"],"categories":[],"sub_categories":[],"readme":"# LeetCode Practice Environment Generator 🚀\n\n[![tests](https://img.shields.io/github/actions/workflow/status/wislertt/leetcode-py/cd.yml?branch=main\u0026label=tests\u0026logo=github)](https://github.com/wislertt/leetcode-py/actions/workflows/cd.yml)\n[![release](https://img.shields.io/github/actions/workflow/status/wislertt/leetcode-py/cd.yml?branch=main\u0026label=release\u0026logo=github)](https://github.com/wislertt/leetcode-py/actions/workflows/cd.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=wislertt_leetcode-py\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=wislertt_leetcode-py)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=wislertt_leetcode-py\u0026metric=security_rating)](https://sonarcloud.io/summary/new_code?id=wislertt_leetcode-py)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=wislertt_leetcode-py\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=wislertt_leetcode-py)\n[![codecov](https://codecov.io/gh/wislertt/leetcode-py/graph/badge.svg?token=TI97VUIA4Z)](https://codecov.io/gh/wislertt/leetcode-py)\n[![pypi](https://img.shields.io/pypi/v/leetcode-py-sdk.svg?color=blue)](https://pypi.python.org/pypi/leetcode-py-sdk)\n[![downloads](https://static.pepy.tech/personalized-badge/leetcode-py-sdk?period=total\u0026units=international_system\u0026left_color=grey\u0026right_color=blue\u0026left_text=pypi%20downloads)](https://pepy.tech/projects/leetcode-py-sdk)\n[![python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue?logo=python)](https://github.com/wislertt/leetcode-py/)\n[![Star ⭐](https://img.shields.io/github/stars/wislertt/leetcode-py?style=flat\u0026logo=github\u0026color=ffcc00)](https://github.com/wislertt/leetcode-py)\n[![Sponsor 💖](https://img.shields.io/badge/Sponsor-💖-pink?style=flat)](https://github.com/sponsors/wislertt)\n\nA Python package to generate professional LeetCode practice environments. Features automated problem generation from LeetCode URLs, beautiful data structure visualizations (TreeNode, ListNode, GraphNode), and comprehensive testing with 10+ test cases per problem. Built with professional development practices including CI/CD, type hints, and quality gates.\n\n## Table of Contents\n\n- [What's Included](#whats-included)\n- [Quick Start](#quick-start)\n- [Problem Structure](#problem-structure)\n- [Key Features](#key-features)\n- [Usage Patterns](#usage-patterns)\n- [Development Setup](#development-setup)\n- [Helper Classes](#helper-classes)\n- [Commands](#commands)\n- [Architecture](#architecture)\n- [Quality Metrics](#quality-metrics)\n\n**What makes this different:**\n\n- 🤖 **[LLM-Assisted Workflow](https://github.com/wislertt/leetcode-py/blob/main/docs/llm-assisted-problem-creation.md)**: Generate new problems instantly with AI assistance\n- 🎨 **Visual Debugging**: Interactive tree/graph rendering with Graphviz and anytree\n- 🧪 **Production Testing**: Comprehensive test suites with edge cases and reproducibility verification\n- 🚀 **Modern Python**: PEP 585/604 type hints, uv, and professional tooling\n- 📊 **Quality Assurance**: 95%+ test coverage, security scanning, automated linting\n- ⚡ **[Powerful CLI](https://github.com/wislertt/leetcode-py/blob/main/docs/cli-usage.md)**: Generate problems anywhere with `lcpy` command\n\n## \u003ca id=\"whats-included\"\u003e\u003c/a\u003e🎯 What's Included\n\n**Current Problem Sets**:\n\n- **grind-75** - Essential coding interview questions from [Grind 75](https://www.techinterviewhandbook.org/grind75/) ✅ Complete\n- **grind** - Extended Grind collection including all Grind 75 plus additional problems 🚧 Partial\n- **blind-75** - Original [Blind 75](https://leetcode.com/problem-list/xi4ci4ig/) curated list ✅ Complete\n- **neetcode-150** - Comprehensive [NeetCode 150](https://neetcode.io/practice) problem set 🚧 Partial\n- **algo-master-75** - Curated algorithmic mastery problems ✅ Complete\n\n**Coverage**: 130+ unique problems across all major coding interview topics and difficulty levels.\n\n**Note**: Some problem sets are partially covered. We're actively working to complete all collections. [Contributions welcome!](https://github.com/wislertt/leetcode-py/blob/main/CONTRIBUTING.md)\n\n## \u003ca id=\"quick-start\"\u003e\u003c/a\u003e🚀 Quick Start\n\n### System Requirements\n\n- **Python 3.10+** - Python runtime\n- **Graphviz** - Required for data structure visualization. Install it before running the project ([install guide](https://graphviz.org/download/))\n\n```bash\n# Install the package\npip install leetcode-py-sdk\n\n# Generate problems anywhere\nlcpy gen -n 1                    # Generate Two Sum\nlcpy gen -t grind-75             # Generate all Grind 75 problems\nlcpy gen -t neetcode-150         # Generate NeetCode 150 problems\nlcpy list -t grind-75            # List Grind 75 problems\nlcpy list -t blind-75            # List Blind 75 problems\n\n# Start practicing\ncd leetcode/two_sum\npython -m pytest test_solution.py  # Run tests\n# Edit solution.py, then rerun tests\n```\n\n### Bulk Generation Example\n\n```bash\nlcpy gen --problem-tag grind-75 --output leetcode     # Generate all Grind 75 problems\nlcpy gen --problem-tag neetcode-150 --output leetcode   # Generate NeetCode 150 problems\nlcpy gen --problem-tag blind-75 --output leetcode       # Generate Blind 75 problems\n```\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/problems-generation.png\" alt=\"Problem Generation\" style=\"pointer-events: none;\"\u003e\n\n_Bulk generation output showing \"Generated problem:\" messages for all 75 Grind problems_\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/problems-generation-2.png\" alt=\"Problem Generation 2\" style=\"pointer-events: none;\"\u003e\n\n_Generated folder structure showing all 75 problem directories after command execution_\n\n## \u003ca id=\"problem-structure\"\u003e\u003c/a\u003e📁 Problem Structure\n\nEach problem follows a consistent, production-ready template:\n\n```\nleetcode/two_sum/\n├── README.md           # Problem description with examples and constraints\n├── solution.py         # Implementation with type hints and TODO placeholder\n├── test_solution.py    # Comprehensive parametrized tests (10+ test cases)\n├── helpers.py          # Test helper functions\n├── playground.py       # Interactive debugging environment (converted from .ipynb)\n└── __init__.py         # Package marker\n```\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/readme-example.png\" alt=\"README Example\" style=\"pointer-events: none;\"\u003e\n\n_README format that mirrors LeetCode's problem description layout_\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/solution-boilerplate.png\" alt=\"Solution Boilerplate\" style=\"pointer-events: none;\"\u003e\n\n_Solution boilerplate with type hints and TODO placeholder_\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/test-example.png\" alt=\"Test Example\" style=\"pointer-events: none;\"\u003e\n\n_Comprehensive parametrized tests with 10+ test cases - executable and debuggable in local development environment_\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/logs-in-test-solution.png\" alt=\"Test Logging\" style=\"pointer-events: none;\"\u003e\n\n_Beautiful colorful test output with loguru integration for enhanced debugging and test result visualization_\n\n## \u003ca id=\"key-features\"\u003e\u003c/a\u003e✨ Key Features\n\n### Production-Grade Development Environment\n\n- **Modern Python**: PEP 585/604 type hints, snake_case conventions\n- **Comprehensive Linting**: black, isort, ruff, mypy with nbqa for notebooks\n- **High Test Coverage**: 10+ test cases per problem including edge cases\n- **Beautiful Logging**: loguru integration for enhanced test debugging\n- **CI/CD Pipeline**: Automated testing, security scanning, and quality gates\n\n### Enhanced Data Structure Visualization\n\nProfessional-grade visualization for debugging complex data structures with dual rendering modes:\n\n- **TreeNode**: Beautiful tree rendering with anytree and Graphviz integration\n- **ListNode**: Clean arrow-based visualization with cycle detection\n- **GraphNode**: Interactive graph rendering for adjacency list problems\n- **DictTree**: Box-drawing character trees perfect for Trie implementations\n\n#### Jupyter Notebook Integration (HTML Rendering)\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/tree-viz.png\" alt=\"Tree Visualization\" style=\"pointer-events: none;\"\u003e\n\n_Interactive tree visualization using Graphviz SVG rendering in Jupyter notebooks_\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/linkedlist-viz.png\" alt=\"LinkedList Visualization\" style=\"pointer-events: none;\"\u003e\n\n_Professional linked list visualization with Graphviz in Jupyter environment_\n\n#### Terminal/Console Output (String Rendering)\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/tree-str-viz.png\" alt=\"Tree String Visualization\" style=\"pointer-events: none;\"\u003e\n\n_Clean ASCII tree rendering using anytree for terminal debugging and logging_\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/linkedlist-str-viz.png\" alt=\"LinkedList String Visualization\" style=\"pointer-events: none;\"\u003e\n\n_Simple arrow-based list representation for console output and test debugging_\n\n### Flexible Notebook Support\n\n- **Template Generation**: Creates Jupyter notebooks (`.ipynb`) by default with rich data structure rendering\n- **User Choice**: Use `jupytext` to convert notebooks to Python files, or keep as `.ipynb` for interactive exploration\n- **Repository State**: This repo converts them to Python files (`.py`) for better version control\n- **Dual Rendering**: Automatic HTML visualization in notebooks, clean string output in terminals\n\n\u003cimg src=\"https://raw.githubusercontent.com/wislertt/leetcode-py/main/docs/images/notebook-example.png\" alt=\"Notebook Example\" style=\"pointer-events: none;\"\u003e\n\n_Interactive multi-cell playground with rich data structure visualization for each problem_\n\n## \u003ca id=\"usage-patterns\"\u003e\u003c/a\u003e🔄 Usage Patterns\n\n### CLI Usage (Global Installation)\n\nPerfect for quick problem generation anywhere. See the 📖 **[Complete CLI Usage Guide](https://github.com/wislertt/leetcode-py/blob/main/docs/cli-usage.md)** for detailed documentation with all options and examples.\n\n## \u003ca id=\"development-setup\"\u003e\u003c/a\u003e🛠️ Development Setup\n\nFor working within this repository to generate additional LeetCode problems using LLM assistance:\n\n### Development Requirements\n\n- **Python 3.10+** - Modern Python runtime with latest type system features\n- **uv** - Fast Python package manager\n- [**Bake**](https://github.com/wislertt/bakefile) - Modern task runner (uses typer for CLI)\n- **Git** - Version control system\n- **Graphviz** - Graph visualization library ([install guide](https://graphviz.org/download/))\n\n```bash\n# Clone repository for development\ngit clone https://github.com/wislertt/leetcode-py.git\ncd leetcode-py\nuv sync\n\n# Generate problems from JSON templates\nbake p-gen -p problem_name\nbake p-test -p problem_name\n\n# Regenerate all existing problems\nbake gen-all-problems\n```\n\n### LLM-Assisted Problem Creation\n\nTo extend the problem collection beyond the current catalog, leverage an LLM assistant within your IDE (Cursor, GitHub Copilot Chat, Amazon Q, etc.).\n\n📖 **[Complete LLM-Assisted Problem Creation Guide](https://github.com/wislertt/leetcode-py/blob/main/docs/llm-assisted-problem-creation.md)** - Comprehensive guide with screenshots and detailed workflow.\n\n**Quick Start:**\n\n```bash\n# Problem generation commands:\n\"Add problem 198. House Robber\"\n\"Add problem 198. House Robber. tag: grind\"\n\n# Test enhancement commands:\n\"Enhance test cases for two_sum problem\"\n\"Fix test reproducibility for binary_tree_inorder_traversal\"\n```\n\n**Required LLM Context**: Include these rule files in your LLM context for automated problem generation and test enhancement:\n\n- [`.claude/commands/problem-creation.md`](https://github.com/wislertt/leetcode-py/blob/main/.claude/commands/problem-creation.md) - Complete problem generation workflow\n- [`.claude/commands/test-quality-assurance.md`](https://github.com/wislertt/leetcode-py/blob/main/.claude/commands/test-quality-assurance.md) - Test enhancement and reproducibility verification\n\n**Manual Check**: Find problems needing more test cases:\n\n```bash\nuv run python -m leetcode_py.tools.check_test_cases --threshold=10\n```\n\n## 🧰 Helper Classes\n\n- **TreeNode**: `from leetcode_py import TreeNode`\n    - Array ↔ tree conversion: `TreeNode.from_list([1,2,3])`, `tree.to_list()`\n    - Beautiful anytree text rendering and Graphviz SVG for Jupyter\n    - Node search: `tree.find_node(value)`\n    - Generic type support: `TreeNode[int]`, `TreeNode[str]`\n\n- **ListNode**: `from leetcode_py import ListNode`\n    - Array ↔ list conversion: `ListNode.from_list([1,2,3])`, `node.to_list()`\n    - Cycle detection with Floyd's algorithm\n    - Graphviz visualization for Jupyter notebooks\n    - Generic type support: `ListNode[int]`, `ListNode[str]`\n\n- **GraphNode**: `from leetcode_py import GraphNode`\n    - Adjacency list conversion: `GraphNode.from_adjacency_list([[2,4],[1,3],[2,4],[1,3]])`\n    - Clone detection: `original.is_clone(cloned)`\n    - Graphviz visualization for undirected graphs\n    - DFS traversal utilities\n\n- **DictTree**: `from leetcode_py.data_structures import DictTree`\n    - Perfect for Trie implementations: `DictTree[str]()`\n    - Beautiful tree rendering with box-drawing characters\n    - Graphviz visualization for Jupyter notebooks\n    - Generic key type support\n\n## 🛠️ Commands\n\n### CLI Commands (Global)\n\n📖 **[Complete CLI Usage Guide](https://github.com/wislertt/leetcode-py/blob/main/docs/cli-usage.md)** - Detailed documentation with all options and examples.\n\n```bash\n# Generate problems\nlcpy gen -n 1                       # Single problem by number\nlcpy gen -s two-sum                 # Single problem by slug\nlcpy gen -t grind-75                # Bulk generation by tag\nlcpy gen -t neetcode-150            # Generate NeetCode 150 problems\nlcpy gen -n 1 -n 2 -n 3            # Multiple problems\nlcpy gen -t grind-75 -d Easy       # Filter by difficulty\nlcpy gen -n 1 -o my-problems       # Custom output directory\n\n# List problems\nlcpy list                           # All available problems\nlcpy list -t grind-75               # Filter by Grind 75 tag\nlcpy list -t blind-75               # Filter by Blind 75 tag\nlcpy list -t neetcode-150           # Filter by NeetCode 150 tag\nlcpy list -d Medium                 # Filter by difficulty\n\n# Scrape problem data\nlcpy scrape -n 1                   # Fetch by number\nlcpy scrape -s two-sum             # Fetch by slug\n```\n\n### Development Commands (Repository)\n\n```bash\n# Problem-specific operations\nbake p-test -p problem_name    # Test specific problem\nbake p-gen -p problem_name     # Generate problem from JSON template\nbake p-gen -p problem_name -f  # Force regenerate (overwrite existing files)\n\n# Bulk operations\nbake test                      # Run all tests\nbake lint                      # Lint entire codebase\nbake gen-all-problems          # Regenerate all problems (destructive)\nbake gen-all-problems -f       # Force regenerate all problems\n```\n\n## 🏗️ Architecture\n\n- **Template-Driven**: JSON templates in `leetcode_py/cli/resources/leetcode/json/problems/` drive code generation\n- **Cookiecutter Integration**: Uses `leetcode_py/cli/resources/leetcode/{{cookiecutter.problem_name}}/` template for consistent file structure\n- **Automated Scraping**: LLM-assisted problem data extraction from LeetCode\n- **Version Control Friendly**: Python files by default, optional notebook support\n\n## 📊 Quality Metrics\n\n- **Test Coverage**: 95%+ with comprehensive edge case testing (Codecov integration)\n- **Security**: SonarCloud quality gates, Trivy dependency scanning, Gitleaks secret detection\n- **Code Quality**: Automated linting with black, isort, ruff, mypy\n- **Test Reproducibility**: Automated verification that problems can be regenerated consistently\n- **CI/CD**: GitHub Actions for testing, security, pre-commit hooks, and release automation\n\nPerfect for systematic coding interview preparation with professional development practices and enhanced debugging capabilities.\n\n## 💖 Support This Project\n\n[![Star ⭐](https://img.shields.io/github/stars/wislertt/leetcode-py?style=flat\u0026logo=github\u0026color=ffcc00)](https://github.com/wislertt/leetcode-py)\n[![Sponsor 💖](https://img.shields.io/badge/Sponsor-💖-pink?style=flat)](https://github.com/sponsors/wislertt)\n\nIf you find this project helpful, please consider **starring the repo ⭐** or **sponsoring my work 💖**.\nYour support helps me maintain and improve this project. Thank you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwislertt%2Fleetcode-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwislertt%2Fleetcode-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwislertt%2Fleetcode-py/lists"}