Posts tagged

Data Structures

Binary Tree Interview Questions: Patterns, Tips, and Solutions

A pattern-first guide to binary tree interview questions. Organizes tree problems into four families: traversal (DFS and BFS), recursive tree properties (depth, balance, sameness), BST-invariant problems (validation, kth smallest), and path problems (lowest common ancestor, max path sum), with full Python solutions, the recursive 'trust the subtree' mental model, complexity analysis, and links to the tree days of the 60-day curriculum.

Hash Maps and Sets: The Most Underrated FAANG Topic

Why hash maps and sets deserve more interview prep time than trees or dynamic programming. Explains the O(1) lookup superpower that turns quadratic brute-force solutions into linear ones, then covers the three patterns behind most hash map interview questions: frequency counting (valid anagram, top-K elements with Counter), the two-sum complement lookup family (two sum, subarray sum equals K with prefix sums), and grouping by canonical key (group anagrams with defaultdict). Includes five fully-solved Python problems, a pattern recognition cheat sheet, complexity analysis, and the follow-up questions interviewers ask about collisions and worst-case behavior.

The Data Structures Cheatsheet: Time & Space Complexity for Every Structure You Need

A single-page reference covering the ten data structures that dominate coding interviews: arrays, linked lists, stacks, queues, hash maps, sets, trees, heaps, graphs, and tries. Each structure gets a complexity table with average and worst-case costs for access, search, insertion, and deletion, plus space complexity, a minimal Python snippet showing idiomatic usage, and guidance on when to reach for it. Includes a master comparison table for quick scanning before an interview and links to the full lessons in the 60-day challenge for deeper study.

Tries Explained Simply (With Real Interview Problems)

A ground-up explanation of the trie (prefix tree) data structure aimed at coding interview preparation. Starts with an intuitive ASCII diagram showing how words share prefixes along root-to-node paths, then explains why tries beat hash sets for prefix queries with O(m) operations independent of dictionary size. Builds a complete, idiomatic Python Trie class with insert, search, and starts_with, analyzing time and space complexity along the way. Applies the structure to three classic interview problems: autocomplete (top-k suggestions per prefix), Word Search II on a 2D board with trie-guided backtracking and pruning, and Longest Word in Dictionary via BFS over complete words, each with a full worked solution.

Dictionaries and Sets: Efficient Data Retrieval

Introduces Python dictionaries as key-value stores, covering creation, access, mutation (add, update, delete), and built-in methods like keys(), values(), and items(). Explains nested dictionaries for representing complex records. Then covers sets as unordered collections of unique elements, demonstrating union, intersection, and difference operations. Ties both together in a phone book exercise that uses a dictionary to store contacts and set semantics to enforce uniqueness, reinforcing when to reach for each data structure.

Lists and Arrays: Storing Collections of Data

Introduces Python lists as ordered, mutable collections and walks through creation, zero-based indexing, negative indexing, and common methods like append, insert, remove, and pop. Also covers list comprehensions for concisely generating filtered or transformed lists, nested lists for representing matrices, and the array module as a memory-efficient alternative for homogeneous numeric data. Concludes with a practical to-do list manager exercise that reinforces add and remove operations interactively.

Arrays and Lists: Mastering Collections in Python

A thorough introduction to Python lists covering creation with mixed types, element access and slicing, and the full set of list methods including sort, reverse, count, and index. Explains list comprehensions for filtering and transforming data, nested lists for 2D data structures, and the array module for typed, memory-efficient numeric storage. The practical section builds a to-do list manager, and a Tic-Tac-Toe challenge invites readers to apply nested lists to model a game board with win detection.