Skip to content

ShadyBad/python_algorithms

Repository files navigation

Python Algorithms

A collection of data structures and algorithms solutions implemented in Python with comprehensive test coverage using pytest.

Overview

This repository contains Python implementations of common DSA problems, primarily sourced from NeetCode. Each solution includes:

  • Clean, efficient implementations with time/space complexity annotations
  • Comprehensive test suites using pytest
  • Links to original problem statements

Problems Implemented

  • Contains Duplicate - Check if an array contains duplicate values
  • Group Anagrams - Group strings that are anagrams of each other
  • Two Sum - Find two numbers that sum to a target value
  • Valid Anagram - Determine if two strings are anagrams

Getting Started

Prerequisites

  • Python 3.x
  • pip

Setup

# Clone the repository
git clone <repository-url>
cd python_algorithms

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On macOS/Linux
# or
venv\Scripts\activate  # On Windows

# Install dependencies
pip install -r requirements.txt

Running Tests

# Run all tests
python -m pytest

# Run specific problem tests
python -m pytest contains_duplicate/test_solution.py

# Run with verbose output
python -m pytest -v

Project Structure

python_algorithms/
├── README.md
├── requirements.txt
├── contains_duplicate/
│   ├── solution.py
│   └── test_solution.py
├── group_anagrams/
│   ├── group_anagrams_solution.py
│   └── test_group_anagrams.py
├── two_sum/
│   ├── two_sum_solution.py
│   └── test_two_sum.py
└── valid_anagram/
    ├── solution.py
    └── test_valid_anagram.py

Each problem directory contains:

  • solution.py - The problem solution with complexity analysis
  • test_*.py - Comprehensive test cases

Contributing

Feel free to add new problems or improve existing solutions. Ensure all new code includes appropriate tests.

About

This repo includes algorithms implemented using Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages