Skip to content

Latest commit

Β 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Python DSA Interview Prep

Python Problems Core 120 Topics License Quality checks

⭐ Star this repo if it helps you crack your interview!

103 solved problems across 15 topics, organized by the patterns and data structures that appear most often in Python interviews. Each solution includes an approach and complexity analysis; priority questions are marked _IMP.

Browse the filterable DSA Prep Atlas or follow the Core 120 roadmap for the planned learning sequence.


πŸ“– Guides

Resource Purpose
🌐 Visual Index Browse all problems in a filterable UI
PATTERNS.md Signal β†’ technique cheat-sheet β€” "which pattern do I use?"
DATA_STRUCTURES.md Requirement β†’ data-structure chooser
ROADMAP.md Follow the curated path from 98 to 120 problems

βœ… Core 120 Progress

Core 120 progress: 103 / 120 problems (86%)

The original 98-problem collection is complete. The repository is now adding 22 carefully selected questions to strengthen thin and missing interview patterns.

# Topic Easy Medium Hard Total
01 Basic and Maths 5 3 0 8
02 Array and Prefix Sum 8 9 0 17
03 Strings 4 4 1 9
04 Hashing 1 4 0 5
05 Two Pointers & Sliding Window 1 3 1 5
06 Stack & Queue 0 3 1 4
07 Linked List 3 2 0 5
08 Trees 5 2 2 9
09 Binary Search 1 2 2 5
10 Greedy Problems 1 5 0 6
11 Dynamic Programming 2 8 1 11
12 Graphs 2 5 0 7
13 Heap & Priority Queue 0 2 2 4
14 Backtracking 0 4 1 5
15 Trie 0 2 1 3
Total 33 58 12 103

Note: TreeNode.py in the Trees folder is a shared helper class, not a problem.
Counts and website mappings are verified automatically in CI: 103 solution files across 15 topic folders.


πŸ“š Topics Covered

1. Basic and Maths

LCM & GCD Β· XOR properties Β· Power and modular exponentiation Β· Sieve of Eratosthenes Β· Perfect squares

2. Array and Prefix Sum

Two Sum Β· 3Sum Β· Kadane's (max subarray) Β· Prefix sum Β· Product of array except self Β· Merge sorted arrays Β· Move zeroes

3. Strings

Valid parentheses Β· Longest substring without repeating Β· Minimum window substring Β· Longest palindromic substring Β· Group anagrams

4. Hashing

Frequency counting Β· Longest consecutive sequence Β· Custom data structure design Β· Count distinct elements in window Β· Valid Sudoku

5. Two Pointers & Sliding Window

Two sum (sorted) Β· Sliding window maximum Β· Maximum consecutive ones Β· Character replacement Β· Permutation in string

6. Stack & Queue

Next greater element Β· Min stack Β· Largest rectangle in histogram Β· Rotten Oranges (multi-source BFS)

7. Linked List

Reverse Β· Loop detection (Floyd's) Β· Merge sorted lists Β· Middle element Β· Remove nth from end

8. Trees

In/Pre/Post-order traversal Β· Level-order Β· Height Β· Diameter Β· LCA Β· Path sum Β· Max path sum Β· Subtree check Β· Serialize & Deserialize

9. Binary Search

Standard binary search Β· Search in rotated sorted array Β· Book allocation Β· Aggressive cows Β· Peak element

10. Greedy Problems

Monster battle Β· Minimum platforms Β· Job sequencing Β· Merge intervals Β· Gas station Β· Fractional knapsack

11. Dynamic Programming

Fibonacci Β· Climbing stairs Β· Coin change Β· LIS Β· LCS Β· 0/1 Knapsack Β· Partition equal sum Β· Max product subarray Β· Edit distance Β· Unique paths Β· House robber

12. Graphs

BFS template Β· DFS (recursive + iterative) Β· Number of Islands Β· Clone Graph Β· Course Schedule (topological sort) Β· Network Delay Time (Dijkstra) Β· Number of Provinces (Union-Find)

13. Heap & Priority Queue

Kth largest element Β· Top K frequent elements Β· Merge K sorted lists Β· Find median from data stream

14. Backtracking

Subsets Β· Permutations Β· Combination sum Β· N-Queens Β· Word search

15. Trie

Implement Trie (prefix tree) Β· Add and search wildcard words Β· Word Search II


πŸ—‚οΈ Repository Structure

β”œβ”€β”€ 01. Basic and maths/        (8 problems)
β”œβ”€β”€ 02. Array and prefix_sum/   (17 problems)
β”œβ”€β”€ 03. Strings/                (9 problems)
β”œβ”€β”€ 04. Hashing/                (5 problems)
β”œβ”€β”€ 05. Two pointers & Sliding window/  (5 problems)
β”œβ”€β”€ 06. Stack & Queue/          (4 problems)
β”œβ”€β”€ 07. Linked List/            (5 problems)
β”œβ”€β”€ 08. Trees/                  (9 problems + TreeNode.py helper)
β”œβ”€β”€ 09. Binary Search/          (5 problems)
β”œβ”€β”€ 10. Greedy Problems/        (6 problems)
β”œβ”€β”€ 11. Dynamic Programming/    (11 problems)
β”œβ”€β”€ 12. Graphs/                 (7 problems)
β”œβ”€β”€ 13. Heap and Priority Queue/ (4 problems)
β”œβ”€β”€ 14. Backtracking/           (5 problems)
β”œβ”€β”€ 15. Trie/                   (3 problems)
β”œβ”€β”€ tests/                       β€” behavior and catalog consistency checks
β”œβ”€β”€ index.html                  β€” filterable visual index
β”œβ”€β”€ PATTERNS.md                 β€” signal β†’ technique cheat-sheet
β”œβ”€β”€ DATA_STRUCTURES.md          β€” requirement β†’ data-structure chooser
└── ROADMAP.md                  β€” path to the Core 120 collection

🎯 How to Use

  1. Clone the repository
    git clone https://github.com/Achal13jain/python-dsa-interview-prep.git
    cd python-dsa-interview-prep
  2. Navigate to a topic folder and open any .py file.
  3. Read or run the solution β€” some files include a if __name__ == "__main__": sample block, and the rest can be tested by calling the function/class directly.
  4. Focus on _IMP files for quick interview prep β€” these are the priority revision picks in this repo.
  5. Read PATTERNS.md to recognise which technique to apply when you see a problem signal.

Run the quality checks

No third-party packages are required:

python -m unittest discover -s tests -v

The suite checks solution behavior, Python 3.9 syntax, duplicate or missing catalog entries, README counts, website mappings, and documentation redirects. GitHub Actions runs the same checks on Python 3.9 and 3.13 for every push and pull request.


πŸ’‘ Problem Markers

  • _IMP β€” Important priority picks for interview revision.
  • Regular files β€” Core problems for building solid fundamentals.

πŸ“– Recommended Learning Path

Beginner

Basic and Maths β†’ Array & Prefix Sum β†’ Strings β†’ Hashing

Intermediate

Two Pointers & Sliding Window β†’ Stack & Queue β†’ Linked List

Advanced

Trees β†’ Binary Search β†’ Greedy β†’ Dynamic Programming
β†’ Graphs β†’ Heap & Priority Queue β†’ Backtracking β†’ Trie

Fast-track Interview Prep (2–3 weeks)

Focus on all _IMP files across every topic. They cover the patterns most likely to appear in a 45-minute interview round.


🀝 Contributing

Found an issue or want to improve a solution?

  1. Fork the repository.
  2. Add or improve a solution using the documented problem template.
  3. Update the website catalog when adding a new problem.
  4. Run python -m unittest discover -s tests -v.
  5. Submit a pull request.

See CONTRIBUTING.md for more details.


πŸ“ License

MIT β€” free to use for learning and interview preparation.


πŸ‘¨β€πŸ’» Author

Achal Jain Β· github.com/Achal13jain


Last updated: September 2026

About

Comprehensive Topic-Wise DSA Problems in Python - Practice code for Data Structures and Algorithms

Topics

Resources

Code of conduct

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages