Skip to content

Commit cd2ee55

Browse files
committed
docs: update README.md
1 parent b22fdbc commit cd2ee55

File tree

10 files changed

+320
-56
lines changed

10 files changed

+320
-56
lines changed

README.md

Lines changed: 107 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,80 @@
99

1010
Premium LeetCode practice environment with modern Python tooling, beautiful tree visualizations, and comprehensive testing.
1111

12+
## 📋 Prerequisites
13+
14+
- Python 3.9+
15+
- make
16+
- git
17+
- Optional: Graphviz for tree visualizations
18+
19+
## 🛠️ Installation
20+
21+
```bash
22+
# Clone the repository
23+
git clone https://github.com/wisarootl/leetcode-py.git
24+
cd leetcode-py
25+
26+
# Install dependencies
27+
pip install -r requirements.txt
28+
29+
# Generate all problems
30+
make gen-all-problems
31+
32+
# Verify setup
33+
make test
34+
```
35+
36+
## 📁 Problem Structure
37+
38+
Each problem follows a consistent template:
39+
40+
```
41+
leetcode/two_sum/
42+
├── README.md # Problem description and examples
43+
├── solution.py # Your implementation with TODO placeholder
44+
├── tests.py # Comprehensive test cases
45+
├── notebook.ipynb # Interactive playground
46+
└── __init__.py # Package marker
47+
```
48+
49+
## 🎯 Supported Problem Categories
50+
51+
- **Arrays & Hashing** - Two Sum, Group Anagrams, Top K Elements
52+
- **Two Pointers** - Valid Palindrome, Container With Most Water
53+
- **Sliding Window** - Longest Substring, Minimum Window
54+
- **Stack** - Valid Parentheses, Daily Temperatures
55+
- **Binary Search** - Search Rotated Array, Find Minimum
56+
- **Linked Lists** - Reverse List, Merge Lists, Detect Cycle
57+
- **Trees** - Invert Tree, Maximum Depth, Serialize/Deserialize
58+
- **Tries** - Implement Trie, Word Search II
59+
- **Heap/Priority Queue** - Merge K Lists, Find Median
60+
- **Backtracking** - Combination Sum, Word Search, N-Queens
61+
- **Graphs** - Clone Graph, Course Schedule, Islands
62+
- **Advanced DP** - Climbing Stairs, Coin Change, LCS
63+
- **Greedy** - Jump Game, Gas Station
64+
- **Intervals** - Merge Intervals, Meeting Rooms
65+
- **Math & Geometry** - Rotate Image, Spiral Matrix
66+
67+
Includes problems from **Blind 75**, **Grind 75**, **NeetCode 150**, and **Top Interview Questions**. This is an ongoing project - contributions are welcome!
68+
69+
## 🎨 Visualizations
70+
71+
### Tree Visualization
72+
73+
![Tree Visualization Placeholder](docs/images/tree-viz.png)
74+
_Beautiful tree rendering with anytree and Graphviz_
75+
76+
### Linked List Visualization
77+
78+
![LinkedList Visualization Placeholder](docs/images/linkedlist-viz.png)
79+
_Clean arrow-based list visualization_
80+
81+
### Jupyter Notebook Integration
82+
83+
![Notebook Placeholder](docs/images/notebook-example.png)
84+
_Interactive multi-cell playground for each problem_
85+
1286
## ✨ Features
1387

1488
- **Template-driven development** - Consistent structure for every problem
@@ -22,6 +96,9 @@ Premium LeetCode practice environment with modern Python tooling, beautiful tree
2296
## 🚀 Quick Start
2397

2498
```bash
99+
# Generate all problems to start practicing
100+
make gen-all-problems
101+
25102
# Run existing problems
26103
make p-test PROBLEM=insert_interval
27104
make p-test PROBLEM=invert_binary_tree
@@ -30,25 +107,42 @@ make p-test PROBLEM=invert_binary_tree
30107
make test
31108
```
32109

33-
**Adding new problems**:
110+
## 🔄 Workflow Examples
34111

35-
- Copy problem and placeholder solution from LeetCode
36-
- Ask LLM to generate them
37-
- LLM follows workflow in `.amazonq/rules/problem-creation.md` using cookiecutter templates
112+
**Practice existing problems**:
113+
114+
```bash
115+
# Work on a specific problem
116+
make p-test PROBLEM=two_sum
117+
# Edit leetcode/two_sum/solution.py
118+
# Run tests to verify
119+
```
38120

39-
## 🧰 Commands
121+
**Add new problems**:
40122

41123
```bash
42-
make p-test PROBLEM=insert_interval # Test specific problem
43-
make test # Run all tests
44-
make lint # Code quality checks
45-
make p-gen PROBLEM=new_prob # Generate new problem
124+
# Copy problem description and solution placeholder from LeetCode
125+
# Then ask your LLM assistant:
126+
# "Create a new LeetCode problem for Valid Anagram"
127+
#
128+
# Behind the scenes, the LLM will:
129+
# 1. Create JSON template following .amazonq/rules/problem-creation.md
130+
# 2. Run `make p-gen PROBLEM=valid_anagram`
131+
# 3. Generate complete problem structure with tests
132+
# 4. You just implement the solution!
46133
```
47134

48-
**🍴 Fork Setup**:
135+
_The LLM follows structured rules in `.amazonq/rules/problem-creation.md` to ensure consistent, high-quality problem generation using proven templates._
136+
137+
**Bulk operations**:
49138

50139
```bash
51-
make gen-all-problems # Regenerate all problems from JSON templates
140+
# Test all problems
141+
make test
142+
# Regenerate all from templates
143+
make gen-all-problems
144+
# Check code quality
145+
make lint
52146
```
53147

54148
## 🧰 Helper Classes
@@ -63,4 +157,6 @@ make gen-all-problems # Regenerate all problems from JSON temp
63157
- Perfect for debugging linked list problems
64158
- New helpers: Add to `leetcode_py/`
65159

160+
This is an ongoing project - contributions are welcome!
161+
66162
Perfect for interview preparation with professional-grade tooling and beautiful visualizations.

docs/images/linkedlist-viz.png

29.6 KB
Loading

docs/images/notebook-example.png

84.4 KB
Loading

docs/images/tree-viz.png

54.2 KB
Loading

leetcode/insert_interval/playground.ipynb

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"id": "imports",
77
"metadata": {},
88
"outputs": [],
@@ -12,31 +12,42 @@
1212
},
1313
{
1414
"cell_type": "code",
15-
"execution_count": null,
15+
"execution_count": 2,
1616
"id": "setup",
1717
"metadata": {},
1818
"outputs": [],
1919
"source": [
20-
"# Example test case",
21-
"intervals = [[1,3],[6,9]]",
22-
"newInterval = [2,5]",
23-
"expected = [[1,5],[6,9]]"
20+
"# Example test case\n",
21+
"intervals = [[1, 3], [6, 9]]\n",
22+
"newInterval = [2, 5]\n",
23+
"expected = [[1, 5], [6, 9]]"
2424
]
2525
},
2626
{
2727
"cell_type": "code",
28-
"execution_count": null,
28+
"execution_count": 3,
2929
"id": "execute",
3030
"metadata": {},
31-
"outputs": [],
31+
"outputs": [
32+
{
33+
"data": {
34+
"text/plain": [
35+
"[[1, 5], [6, 9]]"
36+
]
37+
},
38+
"execution_count": 3,
39+
"metadata": {},
40+
"output_type": "execute_result"
41+
}
42+
],
3243
"source": [
33-
"result = Solution().insert(intervals, newInterval)",
44+
"result = Solution().insert(intervals, newInterval)\n",
3445
"result"
3546
]
3647
},
3748
{
3849
"cell_type": "code",
39-
"execution_count": null,
50+
"execution_count": 4,
4051
"id": "test",
4152
"metadata": {},
4253
"outputs": [],
@@ -59,7 +70,7 @@
5970
"file_extension": ".py",
6071
"mimetype": "text/x-python",
6172
"name": "python",
62-
"nbconvert_exporter": "python3",
73+
"nbconvert_exporter": "python",
6374
"pygments_lexer": "ipython3",
6475
"version": "3.13.7"
6576
}
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
class Solution:
2-
# Time: O(?)
3-
# Space: O(?)
2+
# Time: O(n)
3+
# Space: O(n)
44
def insert(self, intervals: list[list[int]], newInterval: list[int]) -> list[list[int]]:
5-
# TODO: Implement solution
6-
return []
5+
result = []
6+
i = 0
7+
8+
# Add intervals before newInterval
9+
while i < len(intervals) and intervals[i][1] < newInterval[0]:
10+
result.append(intervals[i])
11+
i += 1
12+
13+
# Merge overlapping intervals
14+
while i < len(intervals) and intervals[i][0] <= newInterval[1]:
15+
newInterval[0] = min(newInterval[0], intervals[i][0])
16+
newInterval[1] = max(newInterval[1], intervals[i][1])
17+
i += 1
18+
result.append(newInterval)
19+
20+
# Add remaining intervals
21+
result.extend(intervals[i:])
22+
return result

0 commit comments

Comments
 (0)