Skip to content

Commit c010256

Browse files
committed
docs: update README.md
1 parent 9080a82 commit c010256

12 files changed

+113
-63
lines changed

README.md

Lines changed: 90 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# LeetCode Practice Repository 🚀
1+
# LeetCode Practice Environment Generator 🚀
22

33
[![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)
44
[![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,11 +7,11 @@
77
[![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)
88
[![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)
99

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.
1111

1212
**What makes this different:**
1313

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
1515
- 🎨 **Visual Debugging**: Interactive tree/graph rendering with Graphviz and anytree
1616
- 🧪 **Production Testing**: Comprehensive test suites with edge cases and reproducibility verification
1717
- 🚀 **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
2121

2222
**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.
2323

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.
2525

2626
## 🚀 Quick Start
2727

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)
2935

3036
```bash
31-
# Install globally via pip
37+
# Install the package
3238
pip install leetcode-py
3339

3440
# Generate problems anywhere
3541
lcpy gen -n 1 # Generate Two Sum
3642
lcpy gen -t grind-75 # Generate all Grind 75 problems
3743
lcpy list -t grind-75 # List available problems
3844
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
3950
```
4051

41-
### Development Setup
52+
### Example
4253

4354
```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+
```
5157

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)
5559

56-
# Run all tests
57-
make test
58-
```
60+
_Bulk generation output showing "Generated problem:" messages for all 75 Grind problems_
5961

60-
## 📋 Prerequisites
62+
![Problem Generation 2](docs/images/problems-generation-2.png)
6163

62-
- Python 3.13+
63-
- Poetry, Make, Git, Graphviz
64+
_Generated folder structure showing all 75 problem directories after command execution_
6465

6566
## 📁 Problem Structure
6667

@@ -70,42 +71,77 @@ Each problem follows a consistent, production-ready template:
7071
leetcode/two_sum/
7172
├── README.md # Problem description with examples and constraints
7273
├── 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)
7475
├── helpers.py # Test helper functions
7576
├── playground.py # Interactive debugging environment (converted from .ipynb)
7677
└── __init__.py # Package marker
7778
```
7879

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+
7996
## ✨ Key Features
8097

8198
### Production-Grade Development Environment
8299

83100
- **Modern Python**: PEP 585/604 type hints, snake_case conventions
84101
- **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
86103
- **Beautiful Logging**: loguru integration for enhanced test debugging
87104
- **CI/CD Pipeline**: Automated testing, security scanning, and quality gates
88105

89106
### Enhanced Data Structure Visualization
90107

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:
94109

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
97114

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_
100134

101135
### Flexible Notebook Support
102136

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)
106143

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_
109145

110146
## 🔄 Usage Patterns
111147

@@ -131,31 +167,34 @@ lcpy list -d Medium # Filter by difficulty
131167
lcpy scrape -n 1 > two_sum.json # Save problem data
132168
```
133169

134-
### Development Workflow
170+
## 🛠️ Development Setup
135171

136-
For repository development and customization:
172+
For working within this repository to generate additional LeetCode problems using LLM assistance:
137173

138174
```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
141179

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
146186
```
147187

148188
### LLM-Assisted Problem Creation
149189

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.):
151191

152192
```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"
157196

158-
# For test enhancement (when you need more comprehensive test coverage):
197+
# Test enhancement commands:
159198
"Enhance test cases for two_sum problem"
160199
"Fix test reproducibility for binary_tree_inorder_traversal"
161200
```

docs/images/linkedlist-str-viz.png

21.2 KB
Loading
153 KB
Loading
34.6 KB
Loading
71.9 KB
Loading

docs/images/readme-example.png

81.8 KB
Loading
28.8 KB
Loading

docs/images/test-example.png

108 KB
Loading

docs/images/tree-str-viz.png

15.2 KB
Loading

leetcode_py/cli/utils/problem_finder.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@ def find_problems_by_tag(tag: str) -> list[str]:
1313
try:
1414
with open(tags_file) as f:
1515
tags_data = json5.load(f)
16-
return tags_data.get(tag, [])
16+
17+
problems = []
18+
tag_items = tags_data.get(tag, [])
19+
20+
for item in tag_items:
21+
if isinstance(item, dict) and "tag" in item:
22+
# Resolve tag reference
23+
referenced_problems = find_problems_by_tag(item["tag"])
24+
problems.extend(referenced_problems)
25+
elif isinstance(item, str):
26+
problems.append(item)
27+
28+
return problems
1729
except (ValueError, OSError, KeyError):
1830
return []
1931

@@ -62,9 +74,10 @@ def _add_problem_to_tag_map(
6274
def _process_tag_reference(
6375
tags_data: dict, item: dict, tag_name: str, problem_tags_map: dict[str, list[str]]
6476
) -> None:
65-
for problem_name in tags_data.get(item["tag"], []):
66-
if isinstance(problem_name, str):
67-
_add_problem_to_tag_map(problem_tags_map, problem_name, tag_name)
77+
# Recursively resolve tag references
78+
referenced_problems = find_problems_by_tag(item["tag"])
79+
for problem_name in referenced_problems:
80+
_add_problem_to_tag_map(problem_tags_map, problem_name, tag_name)
6881

6982

7083
def _process_tag_item(

0 commit comments

Comments
 (0)