Skip to content

renishb10/problem_solving_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Top 40 Problem-Solving Interview Questions by Pattern

A curated list of 40 must-practice coding problems commonly asked in top tech interviews, organized by problem-solving patterns.


✅ Patterns Covered

  1. Sliding Window
  2. Two Pointers
  3. Fast & Slow Pointers
  4. Stack
  5. Binary Search
  6. DFS/BFS
  7. Topological Sort
  8. Heap / Priority Queue
  9. Backtracking
  10. Dynamic Programming
  11. Tree DFS/BFS
  12. Prefix Sum / Tricks
  13. Sorting & Greedy
  14. Design
  15. Trie, Union-Find, Matrix Traversal

📋 Problem List

🔄 Sliding Window

  1. Longest Substring Without Repeating Characters
    DS: String, HashSet | Time: O(n)
    Note: Use HashMap/Set to track characters

  2. Minimum Window Substring
    DS: String, HashMap | Time: O(n)
    Note: Two hash maps – one for required, one for window

  3. Sliding Window Maximum
    DS: Deque | Time: O(n)
    Note: Maintain decreasing deque


↔️ Two Pointers

  1. Container With Most Water
    DS: Array | Time: O(n)
    Note: Shrink window from sides, track max area

  2. Trapping Rain Water
    DS: Array | Time: O(n)
    Note: Use leftMax and rightMax pointers


🧮 Hashing / Prefix Suffix

  1. Two Sum
    DS: Array, HashMap | Time: O(n)
    Note: Complement pattern

  2. Product of Array Except Self
    DS: Array | Time: O(n)
    Note: Avoid using division


🌀 Fast & Slow Pointers

  1. Detect Cycle in Linked List
    DS: Linked List | Time: O(n)
    Note: Floyd’s Cycle Detection

  2. Palindrome Linked List
    DS: Linked List | Time: O(n)
    Note: Reverse second half


🧱 Stack

  1. Valid Parentheses
    DS: String, Stack | Time: O(n)
    Note: Match opening and closing

  2. Min Stack
    DS: Stack | Time: O(1) per operation
    Note: Track min with auxiliary stack


🔍 Binary Search

  1. Search in Rotated Sorted Array
    DS: Array | Time: O(log n)
    Note: Handle pivot logic

  2. Find Minimum in Rotated Sorted Array
    DS: Array | Time: O(log n)
    Note: Binary search on rotated array

  3. Median of Two Sorted Arrays
    DS: Array | Time: O(log(min(n,m)))
    Note: Partition logic in binary search


🌐 DFS / BFS

  1. Number of Islands
    DS: Grid | Time: O(m*n)
    Note: Mark visited on grid

  2. Clone Graph
    DS: Graph, HashMap | Time: O(V+E)
    Note: Use visited map

  3. Word Ladder
    DS: Graph | Time: O(N * L^2)
    Note: Transform word by word

  4. Binary Tree Level Order Traversal
    DS: Tree, Queue | Time: O(n)
    Note: Queue for level tracking


⛓ Topological Sort

  1. Course Schedule
    DS: Graph | Time: O(V + E)
    Note: Kahn’s algorithm or DFS cycle detection

🔢 Heap / Priority Queue

  1. Kth Largest Element in Array
    DS: Heap | Time: O(n log k)
    Note: Min Heap of size k

  2. Top K Frequent Elements
    DS: Heap, HashMap | Time: O(n log k)
    Note: Frequency map + Heap

  3. Merge K Sorted Lists
    DS: Linked List, Heap | Time: O(N log k)
    Note: Min Heap of list nodes


🔁 Backtracking

  1. Subsets
    DS: Array | Time: O(2^n)
    Note: DFS include/exclude

  2. Permutations
    DS: Array | Time: O(n!)
    Note: Track used elements

  3. Combination Sum
    DS: Array | Time: O(2^n)
    Note: Include current or skip


📐 Dynamic Programming

  1. Maximum Subarray
    DS: Array | Time: O(n)
    Note: Kadane’s Algorithm

  2. Coin Change
    DS: Array | Time: O(amount * coins)
    Note: Bottom-up DP

  3. Decode Ways
    DS: String | Time: O(n)
    Note: dp[i] = dp[i-1] + dp[i-2]


🌳 Trees (DFS / Recursion / Serialization)

  1. Maximum Depth of Binary Tree
    DS: Tree | Time: O(n)

  2. Lowest Common Ancestor
    DS: Tree | Time: O(n)

  3. Serialize and Deserialize Binary Tree
    DS: Tree | Time: O(n)

  4. Diameter of Binary Tree
    DS: Tree | Time: O(n)


🧮 Others

  1. Merge Intervals
    Pattern: Sorting | Time: O(n log n)

  2. Add Two Numbers
    Pattern: Linked List | Time: O(max(m,n))

  3. LRU Cache
    Pattern: Design | Time: O(1)
    Note: Use HashMap + Doubly Linked List

  4. Jump Game
    Pattern: Greedy | Time: O(n)

  5. Redundant Connection
    Pattern: Union-Find | Time: O(n)

  6. Implement Trie (Prefix Tree)
    Pattern: Trie | Time: O(n)

  7. Daily Temperatures
    Pattern: Monotonic Stack | Time: O(n)

  8. Spiral Matrix
    Pattern: Matrix Traversal | Time: O(m*n)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published