Reusable algorithm templates for LeetCode problems
Project description
LXu_leetcode
LXu_leetcode is a Python utility package that provides reusable algorithm templates and patterns commonly used in solving LeetCode problems. It is designed to help you write cleaner, faster, and more efficient code by importing tried-and-tested patterns directly into your problem-solving workflow.
Features
- Binary Search (standard, lower bound, upper bound)
- Sliding Window (fixed and variable size)
- Two Pointers (e.g., palindrome check, duplicates removal)
- Prefix Sum (range queries, subarray sum)
- Union Find (disjoint set operations)
- Tree and Graph Traversals (DFS, BFS)
- Dynamic Programming (1D, 2D, Knapsack, etc.)
- Trie (prefix trees)
- Backtracking (subsets, permutations)
- Greedy Techniques (e.g., jump game, min_arrows_to_burst_balloons)
- Heap Utilities (e.g., find_k_largest, find_k_smallest, MedianFinder)
- Monotonic Stack (e.g., next_greater_elements, daily_temperatures)
Installation
Install from PyPI:
pip install LXu_leetcode
Usage
from LXu_leetcode.binary_search import binary_search
nums = [1, 3, 5, 7, 9]
target = 5
index = binary_search(nums, target)
print(index) # Output: 2
Folder Structure
LXu_leetcode/
├── binary_search.py
├── sliding_window.py
├── two_pointers.py
├── prefix_sum.py
├── union_find.py
├── graph_algorithms.py
├── dp_templates.py
├── trie.py
├── backtracking.py
├── greedy.py
├── heap_utils.py
├── monotonic_stack.py
Author
LaoXu
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 LXu_leetcode-0.3.tar.gz.
File metadata
- Download URL: LXu_leetcode-0.3.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1f425775ca7cd9eac4a26753d88d2d795dd3ec2b05a2eb512c02086943a5f8c
|
|
| MD5 |
de2b658ea9a649ade6fed0b9382f9e64
|
|
| BLAKE2b-256 |
4f647b99018619b2dc706118d19ab17c6055e5775ad53c676b828f1b8c06af44
|
File details
Details for the file LXu_leetcode-0.3-py3-none-any.whl.
File metadata
- Download URL: LXu_leetcode-0.3-py3-none-any.whl
- Upload date:
- Size: 1.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acf12a01523ffeea0db5cb45313158c51a08422078b9b68f43c7f4016de7df5f
|
|
| MD5 |
3a0edd83a2a274edd716afecdcf3eb19
|
|
| BLAKE2b-256 |
32146fd2b2daadec3ed6024d7c755599056537906c6e45cd2456cd4ef0d7dcf2
|