{"id":42072306,"url":"https://github.com/ianlintner/python_dsa","last_synced_at":"2026-01-26T09:04:48.108Z","repository":{"id":309799888,"uuid":"1037560032","full_name":"ianlintner/python_dsa","owner":"ianlintner","description":"Tech Interview Workbook for Python with Flask Site","archived":false,"fork":false,"pushed_at":"2025-11-30T23:11:57.000Z","size":1546,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-01T01:14:25.075Z","etag":null,"topics":["dsa","leetcode","python"],"latest_commit_sha":null,"homepage":"https://dsa.hugecat.net/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ianlintner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-08-13T18:59:12.000Z","updated_at":"2025-11-29T00:20:11.000Z","dependencies_parsed_at":"2025-08-13T22:26:08.804Z","dependency_job_id":"55ac05cc-775c-4ac0-bb4d-fa5859edec63","html_url":"https://github.com/ianlintner/python_dsa","commit_stats":null,"previous_names":["ianlintner/python_dsa"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ianlintner/python_dsa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlintner%2Fpython_dsa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlintner%2Fpython_dsa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlintner%2Fpython_dsa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlintner%2Fpython_dsa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ianlintner","download_url":"https://codeload.github.com/ianlintner/python_dsa/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ianlintner%2Fpython_dsa/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28771555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T08:38:24.014Z","status":"ssl_error","status_checked_at":"2026-01-26T08:38:22.080Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dsa","leetcode","python"],"created_at":"2026-01-26T09:04:44.702Z","updated_at":"2026-01-26T09:04:48.100Z","avatar_url":"https://github.com/ianlintner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/ianlintner/python_dsa/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ianlintner/python_dsa/actions/workflows/ci.yml)\n\n# Python Interview Algorithms Workbook\n\nClean, idiomatic Python implementations for senior/staff-level interview prep with complexity notes, pitfalls, demos, and tests.\n\n![Project overview screenshot](docs/assets/visual.png)\n\nThis repo uses a src/ layout. Tests import modules directly from src/ via `tests/conftest.py`, so you can run and explore without packaging.\n\n## Quickstart\n\nInstall (editable) and run tests:\n```\npython -m pip install -U pip\npython -m pip install -e .\npytest -q\n```\n\nRun demos:\n```\npython src/main.py --list\npython src/main.py --demo sorting.merge_sort\npython src/main.py --demo searching.binary_search\npython src/main.py --demo dp.lcs\npython src/main.py --demo graphs.scc\n```\n\nTip: If you see an import error when running a demo, run from the repo root (so `./src` is on `sys.path` via our launcher).\n\n## Modules Overview\n\n- algorithms/sorting\n  - comparison: merge, quick (standard/3-way/iterative), heap, insertion, selection, bubble\n  - non-comparison: counting, radix\n- algorithms/searching\n  - binary search family: classic, bounds, range, 2D\n  - advanced: rotated, rotated-with-duplicates, exponential, unknown-size accessor\n  - selection: quickselect (median, kth)\n  - linear search (for unsorted/small inputs)\n- data_structures\n  - Union-Find (DSU), Trie, LRU/LFU caches, Fenwick tree, Segment tree, heap patterns\n- graphs\n  - BFS/DFS, Topological sort, Dijkstra, A*, Bellman-Ford, Floyd-Warshall, MST (Kruskal/Prim), SCC (Tarjan)\n- dp\n  - Fibonacci, coin change, LIS, knapsack, edit distance, bitmask TSP, state compression grid, LCS (longest common subsequence)\n- strings\n  - KMP, Rabin-Karp, Z-algorithm, Manacher, suffix array/LCP\n- math_utils\n  - sieve, gcd/lcm, extended GCD, modular inverse (Fermat/ExtGCD), fast power, prefix sums (1D/2D), difference array\n- patterns\n  - sliding window, monotonic stack/queue, two pointers, backtracking, meet-in-the-middle, binary search on answer\n- systems/concurrency\n  - reservoir sampling, rate limiters, sharded BFS (concept), consensus notes; concurrency intro\n\nEach implementation includes:\n- Time/space complexity analysis\n- Common pitfalls and interviewer follow-ups\n- Clean, production-ready code\n- Demo functions for quick experimentation\n\n## How to use in your own code\n\nImport directly from src/ packages (tests do the same):\n\n- Sorting (stable baseline)\n```\nfrom interview_workbook.algorithms.sorting.insertion_sort import insertion_sort\nprint(insertion_sort([3, 1, 2]))  # [1, 2, 3]\n```\n\n- Sorting (faster average case)\n```\nfrom interview_workbook.algorithms.sorting.quick_sort import quick_sort\nprint(quick_sort([5, 2, 8, 1]))\n```\n\n- Searching (sorted array)\n```\nfrom interview_workbook.algorithms.searching.binary_search import binary_search, lower_bound, upper_bound\narr = [1, 2, 2, 3, 5]\nprint(binary_search(arr, 3))     # 3\nprint(lower_bound(arr, 2))       # 1\nprint(upper_bound(arr, 2))       # 3 (first index \u003e 2)\n```\n\n- Searching (unsorted/small)\n```\nfrom interview_workbook.algorithms.searching.linear_search import linear_search\nprint(linear_search([\"b\", \"a\", \"c\"], \"a\"))  # 1\n```\n\n- DP (LCS)\n```\nfrom interview_workbook.dp.lcs import lcs_length, lcs_reconstruct\nprint(lcs_length(\"abcde\", \"ace\"))     # 3\nprint(lcs_reconstruct(\"abcde\", \"ace\"))# \"ace\"\n```\n\n- Graphs (SCC)\n```\nfrom interview_workbook.graphs.scc import tarjan_scc\ng = {0:[1],1:[2],2:[0,3],3:[4],4:[5],5:[3]}\nprint(tarjan_scc(g))  # e.g., [[0,2,1],[3,5,4]]\n```\n\n## Study guide and interview prep plan\n\nA structured 2–3 week plan with checkpoints, must-know problems, and exercises is provided here:\n- docs/LEARNING_PATH.md\n\nHighlights:\n- Day 1–3: Sorting/bounds/2-pointer patterns; implement insertion/selection/bubble to build fundamentals; graduate to quick/merge/heap\n- Day 4–6: Binary search family, rotated/infinite array, sliding window and monotonic structures\n- Day 7–9: Graphs (BFS/DFS, topo, Dijkstra), MST, SCC; practice classic questions\n- Day 10–12: DP (knapsack, coin change, LIS, edit distance, LCS); practice transitions and state design\n- Strings/math as needed (KMP, Z, Rabin-Karp, prefix sums), plus systems/concurrency notes\n\n## Running and extending tests\n\n- Run all tests: `pytest -q`\n- Add your own tests under `tests/test_*.py`\n- See `tests/test_sorting.py` and `tests/test_searching.py` for structure\n- This PR adds tests for the new sorts and linear search to ensure parity with existing implementations\n\n## Repo layout\n\n- src/…: All implementation modules grouped by domain (algorithms, data_structures, graphs, dp, strings, math_utils, patterns, systems)\n- src/main.py: CLI to list and run demos\n- tests/…: Pytest suite; `tests/conftest.py` places `src/` on the module path\n\n## Contributing\n\n- Keep implementations clean, iterative where appropriate, with clear docstrings\n- Include complexity, pitfalls, and a small `demo()` if practical\n- Extend tests to cover edge cases (empty, single, sorted/reverse, duplicates, random, large)\n\n## Development (linting \u0026 formatting)\n\nLocal setup (editable install + dev tools):\n```\npython -m pip install -U pip\npython -m pip install -e \".[dev]\"\n```\n\nOne-time Git hook setup (runs on commit):\n```\npre-commit install\n```\n\nManual formatting and linting:\n```\n# Format code (Ruff formatter)\nruff format .\n\n# Lint code (Ruff rules E,F,I,B,UP etc.)\nruff check .\n\n# Auto-fix simple issues\nruff check --fix\n```\n\nRun all pre-commit hooks on the whole repo:\n```\npre-commit run --all-files --show-diff-on-failure --color=always\n```\n\nCI runs:\n- Install with extras: `pip install -e \".[dev]\"`\n- Run pre-commit hooks (format + lint + misc checks)\n- Run tests via `pytest -q`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianlintner%2Fpython_dsa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fianlintner%2Fpython_dsa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianlintner%2Fpython_dsa/lists"}