Modern Python LeetCode practice environment with automated problem generation, beautiful data structure visualizations, and comprehensive testing
Project description
LeetCode Practice Environment Generator ๐
A 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.
Table of Contents
- What's Included
- Quick Start
- Problem Structure
- Key Features
- Usage Patterns
- Development Setup
- Helper Classes
- Commands
- Architecture
- Quality Metrics
What makes this different:
- ๐ค LLM-Assisted Workflow: Generate new problems instantly with AI assistance
- ๐จ Visual Debugging: Interactive tree/graph rendering with Graphviz and anytree
- ๐งช Production Testing: Comprehensive test suites with edge cases and reproducibility verification
- ๐ Modern Python: PEP 585/604 type hints, Poetry, and professional tooling
- ๐ Quality Assurance: 95%+ test coverage, security scanning, automated linting
- โก Powerful CLI: Generate problems anywhere with
lcpycommand
๐ฏ What's Included
Current Problem Sets:
- grind-75 - Essential coding interview questions from Grind 75 โ Complete
- grind - Extended Grind collection including all Grind 75 plus additional problems ๐ง Partial
- blind-75 - Original Blind 75 curated list โ Complete
- neetcode-150 - Comprehensive NeetCode 150 problem set ๐ง Partial
- algo-master-75 - Curated algorithmic mastery problems ๐ง Partial
Coverage: 130+ unique problems across all major coding interview topics and difficulty levels.
Note: Some problem sets are partially covered. We're actively working to complete all collections. Contributions welcome!
๐ Quick Start
System Requirements
- Python 3.10+ - Python runtime
- Graphviz - Graph visualization library (install guide)
# Install the package
pip install leetcode-py-sdk
# Generate problems anywhere
lcpy gen -n 1 # Generate Two Sum
lcpy gen -t grind-75 # Generate all Grind 75 problems
lcpy gen -t neetcode-150 # Generate NeetCode 150 problems
lcpy list -t grind-75 # List Grind 75 problems
lcpy list -t blind-75 # List Blind 75 problems
# Start practicing
cd leetcode/two_sum
python -m pytest test_solution.py # Run tests
# Edit solution.py, then rerun tests
Bulk Generation Example
lcpy gen --problem-tag grind-75 --output leetcode # Generate all Grind 75 problems
lcpy gen --problem-tag neetcode-150 --output leetcode # Generate NeetCode 150 problems
lcpy gen --problem-tag blind-75 --output leetcode # Generate Blind 75 problems
Bulk generation output showing "Generated problem:" messages for all 75 Grind problems
Generated folder structure showing all 75 problem directories after command execution
๐ Problem Structure
Each problem follows a consistent, production-ready template:
leetcode/two_sum/
โโโ README.md # Problem description with examples and constraints
โโโ solution.py # Implementation with type hints and TODO placeholder
โโโ test_solution.py # Comprehensive parametrized tests (10+ test cases)
โโโ helpers.py # Test helper functions
โโโ playground.py # Interactive debugging environment (converted from .ipynb)
โโโ __init__.py # Package marker
README format that mirrors LeetCode's problem description layout
Solution boilerplate with type hints and TODO placeholder
Comprehensive parametrized tests with 10+ test cases - executable and debuggable in local development environment
Beautiful colorful test output with loguru integration for enhanced debugging and test result visualization
โจ Key Features
Production-Grade Development Environment
- Modern Python: PEP 585/604 type hints, snake_case conventions
- Comprehensive Linting: black, isort, ruff, mypy with nbqa for notebooks
- High Test Coverage: 10+ test cases per problem including edge cases
- Beautiful Logging: loguru integration for enhanced test debugging
- CI/CD Pipeline: Automated testing, security scanning, and quality gates
Enhanced Data Structure Visualization
Professional-grade visualization for debugging complex data structures with dual rendering modes:
- TreeNode: Beautiful tree rendering with anytree and Graphviz integration
- ListNode: Clean arrow-based visualization with cycle detection
- GraphNode: Interactive graph rendering for adjacency list problems
- DictTree: Box-drawing character trees perfect for Trie implementations
Jupyter Notebook Integration (HTML Rendering)
Interactive tree visualization using Graphviz SVG rendering in Jupyter notebooks
Professional linked list visualization with Graphviz in Jupyter environment
Terminal/Console Output (String Rendering)
Clean ASCII tree rendering using anytree for terminal debugging and logging
Simple arrow-based list representation for console output and test debugging
Flexible Notebook Support
- Template Generation: Creates Jupyter notebooks (
.ipynb) by default with rich data structure rendering - User Choice: Use
jupytextto convert notebooks to Python files, or keep as.ipynbfor interactive exploration - Repository State: This repo converts them to Python files (
.py) for better version control - Dual Rendering: Automatic HTML visualization in notebooks, clean string output in terminals
Interactive multi-cell playground with rich data structure visualization for each problem
๐ Usage Patterns
CLI Usage (Global Installation)
Perfect for quick problem generation anywhere. See the ๐ Complete CLI Usage Guide for detailed documentation with all options and examples.
๐ ๏ธ Development Setup
For working within this repository to generate additional LeetCode problems using LLM assistance:
Development Requirements
- Python 3.10+ - Modern Python runtime with latest type system features
- Poetry - Dependency management and packaging
- Make - Build automation (development workflows)
- Git - Version control system
- Graphviz - Graph visualization library (install guide)
# Clone repository for development
git clone https://github.com/wislertt/leetcode-py.git
cd leetcode-py
poetry install
# Generate problems from JSON templates
make p-gen PROBLEM=problem_name
make p-test PROBLEM=problem_name
# Regenerate all existing problems
make gen-all-problems
LLM-Assisted Problem Creation
To extend the problem collection beyond the current catalog, leverage an LLM assistant within your IDE (Cursor, GitHub Copilot Chat, Amazon Q, etc.).
๐ Complete LLM-Assisted Problem Creation Guide - Comprehensive guide with screenshots and detailed workflow.
Quick Start:
# Problem generation commands:
"Add problem 198. House Robber"
"Add problem 198. House Robber. tag: grind"
# Test enhancement commands:
"Enhance test cases for two_sum problem"
"Fix test reproducibility for binary_tree_inorder_traversal"
Required LLM Context: Include these rule files in your LLM context for automated problem generation and test enhancement:
.cursor/commands/problem-creation.md- Complete problem generation workflow.cursor/commands/test-quality-assurance.md- Test enhancement and reproducibility verification
Manual Check: Find problems needing more test cases:
poetry run python -m leetcode_py.tools.check_test_cases --threshold=10
๐งฐ Helper Classes
-
TreeNode:
from leetcode_py import TreeNode- Array โ tree conversion:
TreeNode.from_list([1,2,3]),tree.to_list() - Beautiful anytree text rendering and Graphviz SVG for Jupyter
- Node search:
tree.find_node(value) - Generic type support:
TreeNode[int],TreeNode[str]
- Array โ tree conversion:
-
ListNode:
from leetcode_py import ListNode- Array โ list conversion:
ListNode.from_list([1,2,3]),node.to_list() - Cycle detection with Floyd's algorithm
- Graphviz visualization for Jupyter notebooks
- Generic type support:
ListNode[int],ListNode[str]
- Array โ list conversion:
-
GraphNode:
from leetcode_py import GraphNode- Adjacency list conversion:
GraphNode.from_adjacency_list([[2,4],[1,3],[2,4],[1,3]]) - Clone detection:
original.is_clone(cloned) - Graphviz visualization for undirected graphs
- DFS traversal utilities
- Adjacency list conversion:
-
DictTree:
from leetcode_py.data_structures import DictTree- Perfect for Trie implementations:
DictTree[str]() - Beautiful tree rendering with box-drawing characters
- Graphviz visualization for Jupyter notebooks
- Generic key type support
- Perfect for Trie implementations:
๐ ๏ธ Commands
CLI Commands (Global)
๐ Complete CLI Usage Guide - Detailed documentation with all options and examples.
# Generate problems
lcpy gen -n 1 # Single problem by number
lcpy gen -s two-sum # Single problem by slug
lcpy gen -t grind-75 # Bulk generation by tag
lcpy gen -t neetcode-150 # Generate NeetCode 150 problems
lcpy gen -n 1 -n 2 -n 3 # Multiple problems
lcpy gen -t grind-75 -d Easy # Filter by difficulty
lcpy gen -n 1 -o my-problems # Custom output directory
# List problems
lcpy list # All available problems
lcpy list -t grind-75 # Filter by Grind 75 tag
lcpy list -t blind-75 # Filter by Blind 75 tag
lcpy list -t neetcode-150 # Filter by NeetCode 150 tag
lcpy list -d Medium # Filter by difficulty
# Scrape problem data
lcpy scrape -n 1 # Fetch by number
lcpy scrape -s two-sum # Fetch by slug
Development Commands (Repository)
# Problem-specific operations
make p-test PROBLEM=problem_name # Test specific problem
make p-gen PROBLEM=problem_name # Generate problem from JSON template
make p-lint PROBLEM=problem_name # Lint specific problem
# Bulk operations
make test # Run all tests
make lint # Lint entire codebase
make gen-all-problems # Regenerate all problems (destructive)
๐๏ธ Architecture
- Template-Driven: JSON templates in
leetcode_py/cli/resources/leetcode/json/problems/drive code generation - Cookiecutter Integration: Uses
leetcode_py/cli/resources/leetcode/{{cookiecutter.problem_name}}/template for consistent file structure - Automated Scraping: LLM-assisted problem data extraction from LeetCode
- Version Control Friendly: Python files by default, optional notebook support
๐ Quality Metrics
- Test Coverage: 95%+ with comprehensive edge case testing (Codecov integration)
- Security: SonarCloud quality gates, Trivy dependency scanning, Gitleaks secret detection
- Code Quality: Automated linting with black, isort, ruff, mypy
- Test Reproducibility: Automated verification that problems can be regenerated consistently
- CI/CD: GitHub Actions for testing, security, pre-commit hooks, and release automation
Perfect for systematic coding interview preparation with professional development practices and enhanced debugging capabilities.
๐ Support This Project
If you find this project helpful, please consider starring the repo โญ or sponsoring my work ๐. Your support helps me maintain and improve this project. Thank you!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file leetcode_py_sdk-0.36.6.tar.gz.
File metadata
- Download URL: leetcode_py_sdk-0.36.6.tar.gz
- Upload date:
- Size: 126.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8db6093d99069d36da2b3344acb33be70672442322ad18a8abf369a67d4f9af1
|
|
| MD5 |
8354bde3b8df734ba0e10d5991ff11dc
|
|
| BLAKE2b-256 |
a4f1a97abd82a3f32ef064c521d38c353a3ab70f249c45f2f85a48050a3ce789
|
Provenance
The following attestation bundles were made for leetcode_py_sdk-0.36.6.tar.gz:
Publisher:
cd.yml on wislertt/leetcode-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leetcode_py_sdk-0.36.6.tar.gz -
Subject digest:
8db6093d99069d36da2b3344acb33be70672442322ad18a8abf369a67d4f9af1 - Sigstore transparency entry: 709146594
- Sigstore integration time:
-
Permalink:
wislertt/leetcode-py@5e3f3bc027818f59f5b5a5268dbc37cf3979dbf3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/wislertt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@5e3f3bc027818f59f5b5a5268dbc37cf3979dbf3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file leetcode_py_sdk-0.36.6-py3-none-any.whl.
File metadata
- Download URL: leetcode_py_sdk-0.36.6-py3-none-any.whl
- Upload date:
- Size: 251.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79b8de7bd2212aac1ab6bdd50b71d3e2b489919810c92323dc9280f9f5949f39
|
|
| MD5 |
60b5d76cad7c427a945a95088f1b102f
|
|
| BLAKE2b-256 |
ede819b3366bbd39df885bca7257000f3ea41f64265210bf3c1c97a2cdb99a62
|
Provenance
The following attestation bundles were made for leetcode_py_sdk-0.36.6-py3-none-any.whl:
Publisher:
cd.yml on wislertt/leetcode-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leetcode_py_sdk-0.36.6-py3-none-any.whl -
Subject digest:
79b8de7bd2212aac1ab6bdd50b71d3e2b489919810c92323dc9280f9f5949f39 - Sigstore transparency entry: 709146610
- Sigstore integration time:
-
Permalink:
wislertt/leetcode-py@5e3f3bc027818f59f5b5a5268dbc37cf3979dbf3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/wislertt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@5e3f3bc027818f59f5b5a5268dbc37cf3979dbf3 -
Trigger Event:
push
-
Statement type: