Skip to content

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.

License

Notifications You must be signed in to change notification settings

wislertt/leetcode-py

Repository files navigation

LeetCode Practice Repository πŸš€

Quality Gate Status Security Rating Vulnerabilities codecov tests release

Premium LeetCode practice repository with Python solutions, algorithm templates, data structure visualizations, and automated testing. Perfect for coding interview preparation, competitive programming, and mastering algorithms with Blind 75, Grind 75, and NeetCode 150 problems.

πŸ“‹ Prerequisites

  • Python 3.13+
  • make, git, Graphviz, poetry

πŸ› οΈ Installation

# Clone the repository
git clone https://github.com/wisarootl/leetcode-py.git
cd leetcode-py

# Install dependencies
pip install -r requirements.txt

# Generate all problems
make gen-all-problems

# Verify setup
make test

πŸ“ Problem Structure

Each problem follows a consistent template:

leetcode/two_sum/
β”œβ”€β”€ README.md          # Problem description and examples
β”œβ”€β”€ solution.py        # Your implementation with TODO placeholder
β”œβ”€β”€ tests.py          # Comprehensive test cases
β”œβ”€β”€ notebook.ipynb    # Interactive playground
└── __init__.py       # Package marker

🎯 Supported Problem Categories

  • Arrays & Hashing - Two Sum, Group Anagrams, Top K Elements
  • Two Pointers - Valid Palindrome, Container With Most Water
  • Sliding Window - Longest Substring, Minimum Window
  • Stack - Valid Parentheses, Daily Temperatures
  • Binary Search - Search Rotated Array, Find Minimum
  • Linked Lists - Reverse List, Merge Lists, Detect Cycle
  • Trees - Invert Tree, Maximum Depth, Serialize/Deserialize
  • Tries - Implement Trie, Word Search II
  • Heap/Priority Queue - Merge K Lists, Find Median
  • Backtracking - Combination Sum, Word Search, N-Queens
  • Graphs - Clone Graph, Course Schedule, Islands
  • Advanced DP - Climbing Stairs, Coin Change, LCS
  • Greedy - Jump Game, Gas Station
  • Intervals - Merge Intervals, Meeting Rooms
  • Math & Geometry - Rotate Image, Spiral Matrix

Includes problems from Blind 75, Grind 75, NeetCode 150, and Top Interview Questions. This is an ongoing project - contributions are welcome!

🎨 Visualizations

Tree Visualization

Tree Visualization Placeholder Beautiful tree rendering with anytree and Graphviz

Linked List Visualization

LinkedList Visualization Placeholder Clean arrow-based list visualization

Jupyter Notebook Integration

Notebook Placeholder Interactive multi-cell playground for each problem

✨ Features

  • Template-driven development - Consistent structure for every problem
  • Beautiful visualizations - TreeNode with anytree/Graphviz, ListNode with arrows
  • Interactive notebooks - Multi-cell playground for each problem
  • One-command testing - make p-test PROBLEM=problem_name
  • Bulk regeneration - make gen-all-problems from JSON templates
  • Full linting - black, isort, ruff, mypy with nbqa for notebooks
  • Modern Python - PEP 585/604 syntax with full type hints

πŸš€ Quick Start

# Generate all problems to start practicing
make gen-all-problems

# Run existing problems
make p-test PROBLEM=insert_interval
make p-test PROBLEM=invert_binary_tree

# Run all tests
make test

πŸ”„ Workflow Examples

Practice existing problems:

# Work on a specific problem
make p-test PROBLEM=two_sum
# Edit leetcode/two_sum/solution.py
# Run tests to verify

Add new problems:

# Copy problem description and solution placeholder from LeetCode
# Then ask your LLM assistant:
# "Create a new LeetCode problem for Valid Anagram"
#
# Behind the scenes, the LLM will:
# 1. Create JSON template following .amazonq/rules/problem-creation.md
# 2. Run `make p-gen PROBLEM=valid_anagram`
# 3. Generate complete problem structure with tests
# 4. You just implement the solution!

The LLM follows structured rules in .amazonq/rules/problem-creation.md to ensure consistent, high-quality problem generation using proven templates.

Bulk operations:

# Test all problems
make test
# Regenerate all from templates
make gen-all-problems
# Check code quality
make lint

🧰 Helper Classes

  • TreeNode: from leetcode_py.tree_node import TreeNode
    • Beautiful tree visualization with anytree rendering
    • Jupyter notebook support with Graphviz diagrams
    • Easy array ↔ tree conversion for testing
  • ListNode: from leetcode_py.list_node import ListNode
    • Clean arrow visualization (1 -> 2 -> 3)
    • Simple array ↔ list conversion
    • Perfect for debugging linked list problems
  • New helpers: Add to leetcode_py/

This is an ongoing project - contributions are welcome!

Perfect for interview preparation with professional-grade tooling and beautiful visualizations.

About

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.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Contributors 2

  •  
  •  

Languages