1
- # LeetCode Practice Repository 🚀
1
+ # LeetCode Practice Environment Generator 🚀
2
2
3
3
[ ![ Quality Gate Status] ( https://sonarcloud.io/api/project_badges/measure?project=wisarootl_leetcode-py&metric=alert_status )] ( https://sonarcloud.io/summary/new_code?id=wisarootl_leetcode-py )
4
4
[ ![ Security Rating] ( https://sonarcloud.io/api/project_badges/measure?project=wisarootl_leetcode-py&metric=security_rating )] ( https://sonarcloud.io/summary/new_code?id=wisarootl_leetcode-py )
7
7
[ ![ tests] ( https://img.shields.io/github/actions/workflow/status/wisarootl/leetcode-py/ci-test.yml?branch=main&label=tests&logo=github )] ( https://github.com/wisarootl/zerv/actions/workflows/ci-test.yml )
8
8
[ ![ release] ( https://img.shields.io/github/actions/workflow/status/wisarootl/leetcode-py/cd.yml?branch=main&label=release&logo=github )] ( https://github.com/wisarootl/zerv/actions/workflows/cd.yml )
9
9
10
- A modern Python LeetCode practice environment that goes beyond basic problem solving . Features automated problem generation from LeetCode URLs, beautiful data structure visualizations (TreeNode, ListNode, GraphNode), and comprehensive testing with 12 + test cases per problem. Built with professional development practices including CI/CD, type hints, and quality gates.
10
+ 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.
11
11
12
12
** What makes this different:**
13
13
14
- - 🤖 ** LLM-Assisted Workflow** : Generate new problems instantly with AI assistance
14
+ - 🤖 ** [ LLM-Assisted Workflow] ( #llm-assisted-problem-creation ) ** : Generate new problems instantly with AI assistance
15
15
- 🎨 ** Visual Debugging** : Interactive tree/graph rendering with Graphviz and anytree
16
16
- 🧪 ** Production Testing** : Comprehensive test suites with edge cases and reproducibility verification
17
17
- 🚀 ** Modern Python** : PEP 585/604 type hints, Poetry, and professional tooling
@@ -21,46 +21,47 @@ A modern Python LeetCode practice environment that goes beyond basic problem sol
21
21
22
22
** Current** : All 75 problems from [ Grind 75] ( https://www.techinterviewhandbook.org/grind75/ ) - the most essential coding interview questions curated by the creator of Blind 75.
23
23
24
- ** Future** : Planned expansion to all 169 Grind problems for comprehensive interview preparation.
24
+ ** Future** : Planned expansion to all free Grind problems for comprehensive interview preparation.
25
25
26
26
## 🚀 Quick Start
27
27
28
- ### CLI Installation (Recommended)
28
+ ### System Requirements
29
+
30
+ - ** Python 3.13+** - Modern Python runtime with latest type system features
31
+ - ** Poetry** - Dependency management and packaging
32
+ - ** Make** - Build automation (development workflows)
33
+ - ** Git** - Version control system
34
+ - ** Graphviz** - Graph visualization library (for data structure rendering)
29
35
30
36
``` bash
31
- # Install globally via pip
37
+ # Install the package
32
38
pip install leetcode-py
33
39
34
40
# Generate problems anywhere
35
41
lcpy gen -n 1 # Generate Two Sum
36
42
lcpy gen -t grind-75 # Generate all Grind 75 problems
37
43
lcpy list -t grind-75 # List available problems
38
44
lcpy scrape -n 1 # Fetch problem data
45
+
46
+ # Start practicing
47
+ cd leetcode/two_sum
48
+ python -m pytest test_solution.py # Run tests
49
+ # Edit solution.py, then rerun tests
39
50
```
40
51
41
- ### Development Setup
52
+ ### Example
42
53
43
54
``` bash
44
- # Clone and setup for development
45
- git clone https://github.com/wisarootl/leetcode-py.git
46
- cd leetcode-py
47
- poetry install
48
-
49
- # Start with existing Grind 75 problems
50
- make gen-all-problems # Regenerates all problems with TODO placeholders
55
+ lcpy gen --problem-tag grind-75 --output leetcode # Generate all Grind 75 problems
56
+ ```
51
57
52
- # Practice a specific problem
53
- make p-test PROBLEM=two_sum
54
- # Edit leetcode/two_sum/solution.py, then rerun tests
58
+ ![ Problem Generation] ( docs/images/problems-generation.png )
55
59
56
- # Run all tests
57
- make test
58
- ```
60
+ _ Bulk generation output showing "Generated problem:" messages for all 75 Grind problems_
59
61
60
- ## 📋 Prerequisites
62
+ ![ Problem Generation 2 ] ( docs/images/problems-generation-2.png )
61
63
62
- - Python 3.13+
63
- - Poetry, Make, Git, Graphviz
64
+ _ Generated folder structure showing all 75 problem directories after command execution_
64
65
65
66
## 📁 Problem Structure
66
67
@@ -70,42 +71,77 @@ Each problem follows a consistent, production-ready template:
70
71
leetcode/two_sum/
71
72
├── README.md # Problem description with examples and constraints
72
73
├── solution.py # Implementation with type hints and TODO placeholder
73
- ├── test_solution.py # Comprehensive parametrized tests (12 + test cases)
74
+ ├── test_solution.py # Comprehensive parametrized tests (10 + test cases)
74
75
├── helpers.py # Test helper functions
75
76
├── playground.py # Interactive debugging environment (converted from .ipynb)
76
77
└── __init__.py # Package marker
77
78
```
78
79
80
+ ![ README Example] ( docs/images/readme-example.png )
81
+
82
+ _ README format that mirrors LeetCode's problem description layout_
83
+
84
+ ![ Solution Boilerplate] ( docs/images/solution-boilerplate.png )
85
+
86
+ _ Solution boilerplate with type hints and TODO placeholder_
87
+
88
+ ![ Test Example] ( docs/images/test-example.png )
89
+
90
+ _ Comprehensive parametrized tests with 10+ test cases - executable and debuggable in local development environment_
91
+
92
+ ![ Test Logging] ( docs/images/logs-in-test-solution.png )
93
+
94
+ _ Beautiful colorful test output with loguru integration for enhanced debugging and test result visualization_
95
+
79
96
## ✨ Key Features
80
97
81
98
### Production-Grade Development Environment
82
99
83
100
- ** Modern Python** : PEP 585/604 type hints, snake_case conventions
84
101
- ** Comprehensive Linting** : black, isort, ruff, mypy with nbqa for notebooks
85
- - ** High Test Coverage** : 12 + test cases per problem including edge cases
102
+ - ** High Test Coverage** : 10 + test cases per problem including edge cases
86
103
- ** Beautiful Logging** : loguru integration for enhanced test debugging
87
104
- ** CI/CD Pipeline** : Automated testing, security scanning, and quality gates
88
105
89
106
### Enhanced Data Structure Visualization
90
107
91
- - ** TreeNode** : Beautiful tree rendering with anytree and Graphviz
92
- - ** ListNode** : Clean arrow-based visualization (` 1 -> 2 -> 3 ` )
93
- - ** Interactive Debugging** : Multi-cell playground environment
108
+ Professional-grade visualization for debugging complex data structures with dual rendering modes:
94
109
95
- ![ Tree Visualization] ( https://raw.githubusercontent.com/wisarootl/leetcode-py/main/docs/images/tree-viz.png )
96
- _ Beautiful tree rendering with anytree and Graphviz_
110
+ - ** TreeNode** : Beautiful tree rendering with anytree and Graphviz integration
111
+ - ** ListNode** : Clean arrow-based visualization with cycle detection
112
+ - ** GraphNode** : Interactive graph rendering for adjacency list problems
113
+ - ** DictTree** : Box-drawing character trees perfect for Trie implementations
97
114
98
- ![ LinkedList Visualization] ( https://raw.githubusercontent.com/wisarootl/leetcode-py/main/docs/images/linkedlist-viz.png )
99
- _ Clean arrow-based list visualization_
115
+ #### Jupyter Notebook Integration (HTML Rendering)
116
+
117
+ ![ Tree Visualization] ( docs/images/tree-viz.png )
118
+
119
+ _ Interactive tree visualization using Graphviz SVG rendering in Jupyter notebooks_
120
+
121
+ ![ LinkedList Visualization] ( docs/images/linkedlist-viz.png )
122
+
123
+ _ Professional linked list visualization with Graphviz in Jupyter environment_
124
+
125
+ #### Terminal/Console Output (String Rendering)
126
+
127
+ ![ Tree String Visualization] ( docs/images/tree-str-viz.png )
128
+
129
+ _ Clean ASCII tree rendering using anytree for terminal debugging and logging_
130
+
131
+ ![ LinkedList String Visualization] ( docs/images/linkedlist-str-viz.png )
132
+
133
+ _ Simple arrow-based list representation for console output and test debugging_
100
134
101
135
### Flexible Notebook Support
102
136
103
- - ** Template Generation** : Creates Jupyter notebooks (` .ipynb ` ) by default
104
- - ** Repository State** : This repo uses Python files (` .py ` ) for better version control
105
- - ** User Choice** : Use ` make nb-to-py ` to convert notebooks to Python files, or keep as ` .ipynb ` for interactive development
137
+ - ** Template Generation** : Creates Jupyter notebooks (` .ipynb ` ) by default with rich data structure rendering
138
+ - ** User Choice** : Use ` jupytext ` to convert notebooks to Python files, or keep as ` .ipynb ` for interactive exploration
139
+ - ** Repository State** : This repo converts them to Python files (` .py ` ) for better version control
140
+ - ** Dual Rendering** : Automatic HTML visualization in notebooks, clean string output in terminals
141
+
142
+ ![ Notebook Example] ( docs/images/notebook-example.png )
106
143
107
- ![ Notebook Example] ( https://raw.githubusercontent.com/wisarootl/leetcode-py/main/docs/images/notebook-example.png )
108
- _ Interactive multi-cell playground for each problem_
144
+ _ Interactive multi-cell playground with rich data structure visualization for each problem_
109
145
110
146
## 🔄 Usage Patterns
111
147
@@ -131,31 +167,34 @@ lcpy list -d Medium # Filter by difficulty
131
167
lcpy scrape -n 1 > two_sum.json # Save problem data
132
168
```
133
169
134
- ### Development Workflow
170
+ ## 🛠️ Development Setup
135
171
136
- For repository development and customization :
172
+ For working within this repository to generate additional LeetCode problems using LLM assistance :
137
173
138
174
``` bash
139
- # Regenerate all 75 problems with fresh TODO placeholders
140
- make gen-all-problems
175
+ # Clone repository for development
176
+ git clone https://github.com/wisarootl/leetcode-py.git
177
+ cd leetcode-py
178
+ poetry install
141
179
142
- # Work through problems systematically
143
- make p-test PROBLEM=two_sum
144
- make p-test PROBLEM=valid_palindrome
145
- make p-test PROBLEM=merge_two_sorted_lists
180
+ # Generate problems from JSON templates
181
+ make p-gen PROBLEM=problem_name
182
+ make p-test PROBLEM=problem_name
183
+
184
+ # Regenerate all existing problems
185
+ make gen-all-problems
146
186
```
147
187
148
188
### LLM-Assisted Problem Creation
149
189
150
- If you need more problems beyond Grind 75, use an LLM assistant in your IDE (Cursor, GitHub Copilot Chat, Amazon Q, etc.):
190
+ To extend the problem collection beyond the current catalog, leverage an LLM assistant within your IDE (Cursor, GitHub Copilot Chat, Amazon Q, etc.):
151
191
152
192
``` bash
153
- # Example commands to give your LLM assistant:
154
- " Create LeetCode problem 146 (LRU Cache)"
155
- " Add problem 'Word Ladder' by number 127"
156
- " Generate problem 'Serialize and Deserialize Binary Tree'"
193
+ # Problem generation commands:
194
+ " Add problem 198. House Robber"
195
+ " Add problem 198. House Robber. tag: grind"
157
196
158
- # For test enhancement (when you need more comprehensive test coverage) :
197
+ # Test enhancement commands :
159
198
" Enhance test cases for two_sum problem"
160
199
" Fix test reproducibility for binary_tree_inorder_traversal"
161
200
```
0 commit comments