Skip to main content

Master 14 essential algorithmic patterns with drop-in Python implementations for LeetCode and coding interviews

Project description

PyLeetPatterns

Master 14 essential algorithmic patterns with drop-in Python implementations for LeetCode and coding interviews.

Production

pip install . # This installs the package normally into your Python environment.

Development

Setup

git clone https://github.com/yourusername/pyleetpatterns.git
cd pyleetpatterns
python3 -m venv .venv
source .venv/bin/activate
pip install -e . # This installs the package in "editable" mode, so changes tothe code are immediately reflected without reinstalling.

# or

pip install -e ".[dev]" # This installs the package in editable mode along with development tools (pytest, black, flake8, mypy).

The [dev] packages are already defined in the setup.py file. Look at lines 30-37:

extras_require={
  "dev": [
      "pytest>=7.0",
      "black>=22.0",
      "flake8>=4.0",
      "mypy>=0.900",
  ]
},

This extras_require section in setup.py defines optional dependencies. When you run:

pip install -e ".[dev]"

It will install:

  1. The package itself in editable mode (-e .)
  2. PLUS all the packages listed under the "dev" key:
  • pytest (for testing)
  • black (for code formatting)
  • flake8 (for linting)
  • mypy (for type checking)

You can add more development dependencies to this list if needed. For example:

extras_require={
  "dev": [
      "pytest>=7.0",
      "black>=22.0",
      "flake8>=4.0",
      "mypy>=0.900",
      "ipython>=8.0",  # for interactive debugging
      "pre-commit>=2.0",  # for git hooks
  ]
},

You could also define other optional dependency groups like:

extras_require={
  "dev": [...],
  "docs": ["sphinx>=4.0", "sphinx-rtd-theme"],
  "viz": ["matplotlib>=3.0", "networkx>=2.0"],
}

Then install them with pip install -e ".[docs]" or pip install -e ".[dev,docs]" for multiple groups.

Testing

pytest

Installation

pip install pyleetpatterns

Quick Start

from pyleetpatterns import PrefixSum, TwoPointers, SlidingWindow

# Example usage
ps = PrefixSum([1, 2, 3, 4, 5])
result = ps.range_sum(1, 3)  # Sum from index 1 to 3

See full documentation in leetcode-patterns-readme.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyleetpatterns-0.1.4.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyleetpatterns-0.1.4-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file pyleetpatterns-0.1.4.tar.gz.

File metadata

  • Download URL: pyleetpatterns-0.1.4.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pyleetpatterns-0.1.4.tar.gz
Algorithm Hash digest
SHA256 741be76fff433d701eff00eae94f3ab888775b3990aeb0a9cb3629eac8b6a4d9
MD5 2fb803cbd421b98cbc6e69df641befe4
BLAKE2b-256 c06d3d9e4ddb4d4c86fc82b6abf377654ed6c928241142ed408f624f0aa177c9

See more details on using hashes here.

File details

Details for the file pyleetpatterns-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: pyleetpatterns-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pyleetpatterns-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1616a893a96b37990e2c7059adf9a8b4bca82f1636c36e1f88056c7d7a0849a7
MD5 aa5abae778d886a90c4ccf53af9415a7
BLAKE2b-256 400bf0a2c444948d15ab6dbf4e358020f6269ecca37f114d4d28bbc894e5c640

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page