Data structures & algorithms, explained clearly
Plain-English answers to the 20 concepts that come up most in coding interviews — each with a direct definition, a correct code example, complexity, common pitfalls and what interviewers actually look for. Every concept is also an animated CodeStory lesson you can watch run step by step.
Searching
Algorithms
Patterns
Two Pointers Two pointers is an algorithmic pattern that uses two indices to traverse a data structure — usually an array or string — instead of one.Sliding Window The sliding window is an algorithm pattern that maintains a moving sub-range over a linear structure like an array or string.Dynamic Programming Dynamic programming is an algorithmic technique that solves a complex problem by breaking it into overlapping subproblems, solving each one only once, and storing the result to reuse later.Backtracking Backtracking is a general technique for solving problems by building a solution one choice at a time and abandoning a partial solution the moment it cannot lead to a valid answer.Greedy Algorithm A greedy algorithm builds a solution step by step, always taking the choice that looks best right now — the locally optimal option — and never undoing it.
Foundations
Complexity
Data Structures
Hash Table A hash table is a data structure that stores key-value pairs and finds any value in O(1) time on average.Array An array is a collection of elements stored side by side in contiguous memory, each reachable by a numeric index.Linked List A linked list is a linear data structure where each element, called a node, stores a value and a pointer (reference) to the next node.Stack A stack is a linear data structure that stores items in last-in, first-out (LIFO) order: the most recently added element is the first one removed.Queue A queue is a linear data structure that stores items in first-in, first-out (FIFO) order: you add elements at the back (enqueue) and remove them from the front (dequeue).Binary Tree A binary tree is a hierarchical data structure made of nodes, where each node holds a value and links to at most two children, called left and right.Heap A heap is a complete binary tree that satisfies the heap property: in a min-heap every parent is smaller than or equal to its children, so the minimum sits at the root (a max-heap flips this).Graph A graph is a data structure that models relationships as a set of vertices (nodes) connected by edges (links).
Graph Algorithms
Breadth-First Search Breadth-first search (BFS) is a graph traversal algorithm that explores a graph level by level, visiting all neighbors of a node before moving deeper.Depth-First Search Depth-first search (DFS) is a graph and tree traversal algorithm that explores as far as possible along each branch before backtracking.
Techniques
Stop memorising. Start understanding.
Every concept here is a lesson you can watch animate, then explain out loud to an AI interviewer that grades you honestly. That is how it moves from “I read it” to “I can do it”.