Skip to content
C Codeloom

Topics / DSA

🧠

DSA

Data Structures and Algorithms — the foundation behind every coding interview and every efficient program.

Why learn DSA?

  • The shared vocabulary of every coding interview at every company.

  • Lets you reason about performance before you write the code.

  • Sharpens problem-solving in a way nothing else does.

  • A single skill that compounds across every language and framework.

What you can build with DSA

Cracking technical interviews Writing code that scales Reading other engineers' code faster Competitive programming and contests

DSA tutorials

90 articles

Hand-written tutorials, ordered as a recommended learning path.

  1. 01 What Is DSA? A beginner-friendly introduction to data structures and algorithms — what they are, why they matter for interviews and real performance, and how to actually start learning DSA.
  2. 02 Big-O Notation A practical guide to Big-O notation — O(1), O(log n), O(n), O(n log n), O(n^2), and beyond, with code examples, best/average/worst case, and a brief look at amortized and space complexity.
  3. 03 Arrays — Intro A beginner's introduction to arrays — contiguous memory, indexing, the Python list vs C array caveat, time complexity of read/write/insert/delete, and 1D vs 2D arrays.
  4. 04 Arrays — Operations The everyday array patterns every DSA learner should know — traversal, linear search, insertion, deletion, reversal, rotation, prefix sums, Kadane's preview, and the one-pass habit.
  5. 05 Arrays — Practice Ten classic array interview problems with examples, approach, complexity, and clean Python solutions — Two Sum, Best Time to Buy/Sell Stock, Kadane's, Rotate Array, Product Except Self, and more.
  6. 06 Strings — Intro An introduction to strings for data structures and algorithms — immutability, indexing, slicing, common operations, ASCII versus Unicode, and the two-pointer and frequency-counter patterns you will use everywhere.
  7. 07 Pattern Matching A practical tour of substring search — the naive O(n·m) scan, the KMP algorithm with its LPS array, and the Rabin-Karp rolling hash. Worked examples, code, and intuition for when to use each.
  8. 08 Strings — Practice Eight classic string problems with worked Python solutions — Valid Anagram, Group Anagrams, Longest Substring Without Repeating Characters, Longest Palindromic Substring, and more.
  9. 09 Hashing & Hash Maps How hash functions, hash maps, and hash sets work — the intuition behind buckets and collisions, chaining vs open addressing, average and worst-case complexity, and the Python containers built on them.
  10. 10 Hashing — Practice Eight classic hash map problems with worked Python solutions — Two Sum, Group Anagrams, Subarray Sum Equals K, Longest Consecutive Sequence, Top K Frequent Elements, and more.
  11. 11 Linked Lists — Intro A practical introduction to linked lists — what a node is, singly vs doubly linked, head and tail, how arrays and linked lists differ, and a clean Python implementation you can build on.
  12. 12 LL Operations The core operations every linked list problem builds on — inserting at head/tail/middle, deleting by value, reversing iteratively and recursively, finding the middle, and detecting a cycle.
  13. 13 LL — Practice Eight classic linked-list interview problems — reverse, detect cycle, merge sorted lists, remove Nth from end, cycle start, palindrome, add two numbers, and intersection — each with a worked Python solution.
  14. 14 Stacks & Queues A practical introduction to stacks and queues — LIFO vs FIFO, using a Python list as a stack, collections.deque as a queue, and the real-world problems each one solves cleanly.
  15. 15 Stacks/Queues — Practice Eight classic stack and queue interview problems with worked Python solutions — Valid Parentheses, Min Stack, Daily Temperatures, Sliding Window Maximum, and more.
  16. 16 Binary Trees — Intro A practical introduction to binary trees — the TreeNode class, terminology (full, complete, perfect, balanced), height vs depth, BSTs, and the small calculations you need to reason about tree problems.
  17. 17 Tree Traversals A practical guide to the four canonical binary tree traversals — recursive and iterative versions, when to use each, and the patterns that make them click.
  18. 18 Trees — Practice Eight classic binary tree interview problems with examples, approach notes, and clean Python solutions — max depth, same tree, invert, symmetric, path sum, LCA, validate BST, and serialize/deserialize.
  19. 19 Graphs — Intro A practical introduction to graphs — directed vs undirected, weighted vs unweighted, cyclic vs acyclic, and the three main representations (adjacency list, adjacency matrix, edge list) with Python code.
  20. 20 BFS & DFS A practical guide to BFS and DFS on graphs — recursive and iterative DFS, BFS with a deque, shortest paths on unweighted graphs, connected components, cycle detection, and five classic practice problems.
  21. 21 Recursion Basics A practical introduction to recursion — the base case, the recursive case, the call stack, and how to think about problems that solve themselves through smaller versions of themselves.
  22. 22 DP — Intro An introduction to dynamic programming — overlapping subproblems, optimal substructure, top-down memoization, and bottom-up tabulation, with worked examples in Python.
  23. 23 DP — Practice Eight classic dynamic programming problems — Climbing Stairs, House Robber, Coin Change, LIS, Word Break, 0/1 Knapsack, Edit Distance, and LCS — each with Python solutions and DP tables.
  24. 24 Bit Manipulation A practical introduction to bit manipulation in Python — binary representation, the bitwise operators, two's complement, and the common operations to set, clear, toggle, and check individual bits.
  25. 25 Bit Tricks Six classic bit manipulation problems — Single Number, Number of 1 Bits, Power of Two, Counting Bits, Missing Number, Reverse Bits — plus the tricks that make them tick: n & (n-1), n & -n, and XOR cancellation.
  26. 26 Two Pointers A practical guide to the two pointers technique — opposite-end and same-direction patterns, when to use each, and six classic interview problems with worked solutions.
  27. 27 Sliding Window A practical guide to sliding window — fixed-size vs variable-size windows, expand/shrink invariants, and six classic problems with worked Python solutions.
  28. 28 Sorting Overview A tour of the five sorting algorithms every programmer should know — their ideas, Big-O time and space, stability, and Python implementations, plus when to just use sort().
  29. 29 Binary Search A practical guide to binary search — the classic template, off-by-one traps, Python's bisect module, and the binary-search-on-answer pattern, with six worked problems.
  30. 30 Greedy An introduction to greedy algorithms — when the locally best choice gives a globally optimal answer, when it doesn't, the exchange argument, and six classic problems.
  31. 31 LC 98 — Validate BST LeetCode 98 in full — the seductive wrong answer, the correct min/max bounds approach, and how to defend it in an interview.
  32. 32 LC 235 — LCA of BST LeetCode 235 walked through end to end — why BST ordering collapses LCA into a one-line traversal, and the iterative version that needs zero extra space.
  33. 33 LC 230 — Kth Smallest BST LeetCode 230 in detail — the inorder traversal trick, the iterative early-exit version, and the follow-up that haunts FAANG interviews.
  34. 34 LC 297 — Serialize Tree LeetCode 297 fully unpacked — the preorder-with-nulls encoding, the iterator-driven decoder, and why level-order is a worse choice than it looks.
  35. 35 LC 112 — Path Sum LeetCode 112 in detail — the DFS-with-decrement trick, why the leaf condition is the whole problem, and the variants that build on it.
  36. 36 LC 102 — Level Order LeetCode 102 in detail — the queue-with-size BFS pattern, why DFS still works, and how this template extends to zigzag and right-side view.
  37. 37 LC 133 — Clone Graph LeetCode 133 walked through — why a hash map from original to copy is the entire idea, plus the BFS variant for stack-limited environments.
  38. 38 LC 417 — Pacific Atlantic LeetCode 417 explained — why you should flood from the oceans inward, not from each cell outward, and how the intersection gives the answer.
  39. 39 LC 127 — Word Ladder LeetCode 127 walked through — the wildcard-pattern adjacency trick, why BFS is mandatory, and the bidirectional speedup.
  40. 40 LC 300 — LIS LeetCode 300 in detail — the O(n^2) DP, the O(n log n) patience-sorting trick with binary search, and when each one matters.
  41. 41 LC 72 — Edit Distance LeetCode 72 fully unpacked — the three-operation recurrence, the 2D table, and the rolling-array space optimization that makes interviewers nod.
  42. 42 LC 62 — Unique Paths LeetCode 62 in two ways — the O(m * n) grid DP that interviewers expect and the binomial-coefficient closed form that surprises them.
  43. 43 Backtracking A practical guide to backtracking: the recursion template, pruning, classic problems with code, and complexity analysis for subsets and permutations.
  44. 44 Divide & Conquer Learn the divide-and-conquer pattern through merge sort and quick sort, recurrence relations, the Master theorem, and how to recognize the pattern.
  45. 45 Heaps Learn how heaps power priority queues, why heapq runs push and pop in O(log n), and how to solve classic Top-K and merge problems in Python.
  46. 46 3Sum A careful walkthrough of LeetCode 15 3Sum using sort plus two pointers. We handle duplicate triplets cleanly and avoid the classic off-by-one traps.
  47. 47 Buy Sell Stock Walk through LeetCode 121 Best Time to Buy and Sell Stock. We go from the quadratic brute force to a clean one-pass solution tracking the running minimum.
  48. 48 Climbing Stairs Walk through LeetCode 70 Climbing Stairs from brute force recursion to bottom-up DP, with edge cases, complexity analysis, and an interview script.
  49. 49 Coin Change Walk through LeetCode 322 Coin Change with brute force recursion, memoization, and bottom-up DP. Includes complexity analysis and interview script.
  50. 50 Container Water Solve LeetCode 11 Container With Most Water with the two-pointer technique. We prove correctness and contrast it with the quadratic brute force.
  51. 51 Course Schedule Detect cycles and produce a valid course order in LeetCode 207 Course Schedule using DFS-based topological sort. Includes BFS Kahn alternative and interview script.
  52. 52 Daily Temperatures Solve LeetCode Daily Temperatures with a monotonic decreasing stack of indices. Includes brute force comparison, walkthrough, complexity, and interview tips.
  53. 53 Group Anagrams Solve LeetCode Group Anagrams cleanly with a hash map keyed by sorted strings or character counts. Includes complexity analysis and interview talking points.
  54. 54 House Robber Solve LeetCode 198 House Robber with the pick-or-skip DP recurrence, then optimize to O(1) space. Includes interview script and related variants.
  55. 55 Invert Tree Solve LeetCode 226 Invert Binary Tree with a four-line recursive swap and an iterative BFS alternative, including complexity and interview talking points.
  56. 56 Longest Palindrome Walk through LeetCode Longest Palindromic Substring using the expand-around-center technique. Compare brute force, DP, and the optimal approach with examples.
  57. 57 Longest Substring Solve LeetCode 3 Longest Substring Without Repeating Characters using a sliding window with a hash map. We go from brute force to a clean O(n) sweep.
  58. 58 LRU Cache Design LeetCode 146 LRU Cache with a hash map and a doubly linked list to get O(1) get and put, with a clean Python implementation and interview tips.
  59. 59 Max Depth Solve LeetCode 104 Maximum Depth of Binary Tree with a three-line recursive DFS and an iterative BFS alternative, with complexity analysis and interview tips.
  60. 60 Max Subarray A clear walkthrough of LeetCode 53 Maximum Subarray. We build Kadane's algorithm from first principles and contrast it with the divide and conquer approach.
  61. 61 Merge Two Lists Solve LeetCode 21 Merge Two Sorted Lists with the dummy-head pointer pattern, plus a recursive variant, edge cases, and interview explanation tips.
  62. 62 Min Stack Design a stack that supports push, pop, top, and getMin in constant time. Walkthrough of the two-stack and pair-stack solutions with edge cases and interview tips.
  63. 63 Num Islands Solve LeetCode 200 Number of Islands with grid DFS and BFS, including a union-find variant, edge-case handling, and clear interview talking points.
  64. 64 Reverse Linked List Walk through LeetCode 206 Reverse Linked List with iterative pointer flipping and a clean recursive solution, plus complexity and interview talking points.
  65. 65 Subsets Generate all subsets of an array in LeetCode 78 using backtracking and iterative bit-mask approaches. Includes complexity analysis and interview script.
  66. 66 Two Sum A complete walkthrough of LeetCode 1 Two Sum. We move from the obvious nested loop to a single-pass hash map and dissect why it works.
  67. 67 Valid Parentheses A clean walkthrough of LeetCode Valid Parentheses with the optimal stack solution. Covers edge cases, complexity, and how to explain the approach in interviews.
  68. 68 Valid Anagram A complete walkthrough of LeetCode Valid Anagram. Compare the sorting approach with the optimal hash map counting solution and learn how to explain it in interviews.
  69. 69 Word Break Solve LeetCode 139 Word Break with bottom-up dynamic programming. Includes brute force, edge cases, complexity analysis, and an interview script.
  70. 70 Interview Math The essential math toolkit for interviews: Euclidean GCD, sieve of Eratosthenes, modular exponentiation, modular inverses, and common pitfalls.
  71. 71 Tries A practical introduction to tries: node structure, insert, search, prefix queries, memory tradeoffs, and classic interview problems like word search.
  72. 72 Union-Find Learn the union-find data structure with union by rank and path compression, why it runs in near-O(1) amortized, and how it powers Kruskal and islands.
  73. 73 Bellman-Ford Understand Bellman-Ford's relaxation loop, how it handles negative edges, detects negative cycles, and why it costs more than Dijkstra.
  74. 74 Dijkstra Learn Dijkstra's shortest path algorithm with a clean Python implementation, complexity analysis, and the priority queue intuition behind it.
  75. 75 Fenwick Tree Implement and understand the Fenwick tree, also called the binary indexed tree, for O(log n) prefix sums and point updates in just a few lines.
  76. 76 MST: Kruskal & Prim Build minimum spanning trees with Kruskal's union-find approach and Prim's priority queue approach, with side-by-side Python implementations.
  77. 77 Combination Sum Solve LeetCode 39 Combination Sum with a clean backtracking template. Pruning, duplicate avoidance, complexity discussion, and interview script.
  78. 78 Generate Parentheses Solve LeetCode 22 Generate Parentheses with counting-based backtracking. Clean invariant, walkthrough, complexity discussion, and interview tips.
  79. 79 Phone Letters Solve LeetCode 17 Letter Combinations of a Phone Number with backtracking. Mapping setup, recursive enumeration, complexity, and interview walkthrough.
  80. 80 Longest Consecutive Solve LeetCode 128 Longest Consecutive Sequence in O(n) using a hash set and a start-of-run check. Walkthrough, edge cases, and interview script.
  81. 81 Permutations Solve LeetCode 46 Permutations with backtracking and a used array. Compare swap-in-place vs used-array, walkthrough, complexity, and interview tips.
  82. 82 Product Except Self Solve LeetCode 238 Product of Array Except Self in O(n) without division using prefix and suffix passes. Clean walkthrough plus interview script.
  83. 83 Rotate Image Solve LeetCode 48 Rotate Image in place by transposing and reversing each row. Walkthrough, edge cases, complexity, and interview script.
  84. 84 Rotated Search Solve LeetCode 33 Search in Rotated Sorted Array in O(log n) with modified binary search. Pivot detection, half-decision logic, and interview talking points.
  85. 85 Sliding Window Max Solve LeetCode 239 Sliding Window Maximum in O(n) using a monotonic deque. Step-by-step walkthrough, interview script, and complexity analysis.
  86. 86 Spiral Matrix Solve LeetCode 54 Spiral Matrix with the four-boundary walk pattern. Clean implementation, edge cases for rectangles, complexity, and interview tips.
  87. 87 Top K Frequent Solve LeetCode 347 Top K Frequent Elements with both a min-heap and a bucket sort approach. Trade-offs, complexity, and interview-ready walkthrough.
  88. 88 Trapping Rain Water Solve LeetCode 42 Trapping Rain Water in linear time and constant space using the two-pointer technique. Brute force, optimal walkthrough, and interview talk track.
  89. 89 Segment Tree Learn segment trees for fast range sum, min, and max queries with point updates, including a clean iterative Python implementation.
  90. 90 Topological Sort Compare Kahn's BFS-based topological sort with DFS-based postorder, with Python implementations, complexity, and cycle detection.