Skip to content

Latest commit

 

History

History

README.md

🐍 Python LeetCode — Solved Answersheet

Interview-grade, fully-explained solutions to the problems in ../guides/Python_Leetcode.md, organized by pattern. Built as study material for an AI/ML Engineer interview track.

Every solution is PEP 8 / pylint-clean, type-hinted, paste-ready into the LeetCode editor, and self-testing (python file.py runs its examples). The module docstring teaches the pattern and the why, not just the code. See STYLE.md for the standard and TEMPLATE.py for the canonical shape.

How to use this folder

  1. Pick a category folder. Read its README.md — it frames the pattern and lists every problem with its key idea and complexity.
  2. Attempt the problem cold (20-min timer). Then read the solution file.
  3. Run it: python 01-arrays-hashing/0001_two_sum.pyAll tests passed.
  4. Re-do anything you couldn't solve in time. Patterns over volume.

Categories

# Folder Pattern focus ML relevance
01 01-arrays-hashing Hash maps, sets, frequency counts Dedup, vocab building, embedding lookups
02 02-two-pointers Opposite / slow-fast pointers In-place array ops
03 03-sliding-window Fixed & variable windows Sequence/window stats, pooling
04 04-stack Stack matching, monotonic stack Expression parsing
05 05-linked-list Pointer manipulation, Floyd's cycle Streaming structures
06 06-trees DFS/BFS, recursion, BST property Decision trees, hierarchies
07 07-binary-search Classic + search-on-answer Threshold tuning
08 08-math-bit-manipulation Bit tricks, integer math Masking, hashing
09 09-dynamic-programming 1-D DP, memoization Sequence models, DTW intuition
10 10-graphs Grid DFS/BFS GNNs, knowledge graphs

Progress

Phase 1 — Easy (this answersheet): all 60 Easy problems solved to gold standard.

Category Easy Medium Hard
Arrays & Hashing ✅ 10/10 scaffolded scaffolded
Two Pointers ✅ 7/7 scaffolded
Sliding Window ✅ 3/3 scaffolded scaffolded
Stack ✅ 4/4 scaffolded
Linked List ✅ 6/6 scaffolded
Trees ✅ 10/10 scaffolded scaffolded
Binary Search ✅ 4/4 scaffolded scaffolded
Math & Bit ✅ 9/9 scaffolded
Dynamic Programming ✅ 5/5 scaffolded scaffolded
Graphs ✅ 2/2 scaffolded scaffolded

Medium and Hard tiers are listed in each category README as the next phase.

Conventions

  • Naming: folders NN-kebab-case, files NNNN_snake_case_title.py.
  • Self-contained: helper types (TreeNode, ListNode) are defined in-file, exactly as LeetCode provides them. Solution bodies import only the standard library.
  • Idioms ML interviewers notice: collections.Counter, defaultdict, deque, heapq, bisect used fluently and deliberately.