Algorithms
Techniques for solving problems efficiently.
5 subjects · 38 topics · 11 areas · 6 cheatsheets
Subjects covering this category
5 subjects- Subject · Intermediate to Advanced
Tracing, implementing and proving the cost of the classic searching, sorting and graph algorithms, and designing new ones with divide and conquer, backtracking, greedy choice and dynamic programming, in Python, Java and TypeScript.
- Searching and Simple Sorting
- Efficient Sorting
- Design Strategies
- Subject · Intermediate to Advanced
Recognising which of the common problem-solving patterns an unseen coding problem needs, and solving it in Python, Java or TypeScript within the time an interview allows.
- Approach
- Array and Number Patterns
- Linked List Patterns
- Subject · Beginner to Advanced
Choosing a data structure by the cost of its operations, and implementing arrays, linked lists, stacks, queues, hash tables, trees, heaps, tries and graphs in Python, Java and TypeScript.
- Measuring Cost
- Sequences and Lookup
- Recursion and Trees
- Subject · Intermediate to Advanced
Holding data in the right Java collection, and transforming it without writing a loop.
- Collections
- Pipelines
- Subject · Beginner to Advanced
Turning a product's requirements into a first design for a web system, and knowing what each part is there for.
- Starting a Design
- The Parts of a System
- Moving Data Around
Cheatsheets
6 cheatsheets- Cheatsheet · Algorithms
Traversal, ordering, shortest paths, spanning trees and connectivity on one page: which algorithm a graph question needs and what it costs.
- Cheatsheet · Coding Interview Patterns
Fourteen coding interview patterns on one page: the property that points to each, what it costs, when it fails, and its loop in Python.
- Cheatsheet · Algorithms
Every sort the subject teaches beyond the simple three on one page: what each costs, what it needs, and which one to call.
- Cheatsheet · Algorithms
Backtracking, greedy algorithms and dynamic programming on one page: when each fits, and the Python that shows its shape.
- Cheatsheet · Algorithms
Binary search and the three simple sorts on one page: when each fits, what it costs, and the Python to write it.
- Cheatsheet · Java Collections and Streams
Every everyday Java collection on one page: what each one is for, what it costs, and how to choose.
Sorting Algorithms
9 topics- Algorithms
Elementary sorting: bubble, selection and insertion sort traced pass by pass, and the one place each still beats an O(n log n) algorithm.
Intermediate11 cards · 5 qnot started
- Algorithms
Linear-time sorting: counting, radix and bucket sort, which beat the comparison bound by reading the keys' values, and the inputs each one needs.
Intermediate to Advanced11 cards · 5 qnot started
- Java Collections and Streams
Sorting your own types in Java: Comparable for the natural order, Comparator for the rest, and the two ways a comparator goes wrong.
Intermediate to Advanced9 cards · 5 qnot started
- Algorithms
Quicksort: sorting by partitioning around a pivot, fast on average, slow on the inputs a bad pivot meets, and the source of quickselect.
Intermediate to Advanced9 cards · 4 qnot started
- Algorithms
Merge sort: the sorting algorithm that splits an array in half, sorts each half and merges them, in O(n log n) time on every input.
Intermediate8 cards · 4 qnot started
- Algorithms
Choosing a sorting algorithm: picking a sort by memory, stability, worst case and keys, the n log n limit on comparison sorts, and built-in sorts.
Intermediate to Advanced8 cards · 4 qnot started
- Coding Interview Patterns
Intervals: merging, inserting and intersecting ranges after sorting them by start, and counting the most that overlap at once.
Intermediate to Advanced8 cards · 4 qnot started
- Algorithms
Heapsort: sorting in place in O(n log n) time on every input by building a heap and extracting its largest item, one at a time.
Intermediate7 cards · 3 qnot started
- Java Collections and Streams
Java lambdas and functional interfaces: passing behaviour as an argument, the four core interfaces, method references and captured variables.
Intermediate to Advanced9 cards · 5 qnot started
Graph Algorithms
7 topics- Algorithms
Shortest paths in weighted graphs, in algorithms: Dijkstra's algorithm, Bellman-Ford and Floyd-Warshall, and how weights and pairs choose between them.
Intermediate to Advanced11 cards · 6 qnot started
- Algorithms
Breadth-first and depth-first search in algorithms, and what they find: components, cycles, bipartite graphs and unweighted shortest paths.
Intermediate to Advanced10 cards · 6 qnot started
- Algorithms
Minimum spanning trees in algorithms: the cut property, Kruskal's algorithm with union-find, Prim's algorithm with a heap, and why neither gives shortest paths.
Intermediate to Advanced9 cards · 4 qnot started
- Algorithms
Ordering tasks so every dependency comes first, in algorithms: Kahn's algorithm, depth-first finishing times, and how each one finds a cycle.
Intermediate to Advanced8 cards · 4 qnot started
- Coding Interview Patterns
Grid traversal: treating a grid of cells as a graph for breadth-first and depth-first search, flood fills and searches from many starting cells.
Intermediate to Advanced8 cards · 4 qnot started
- Coding Interview Patterns
Graph modelling: finding the vertices and edges hidden in a problem's wording, then solving it with a search, a topological sort or union-find.
Intermediate to Advanced8 cards · 4 qnot started
- Algorithms
Graph connectivity in algorithms: strongly connected components with Kosaraju's two passes, bridges and articulation points from low values, and choosing the tool.
Intermediate to Advanced7 cards · 3 qnot started
Dynamic Programming
4 topics- Algorithms
Dynamic programming: solving a problem from the answers to its overlapping subproblems, top-down with memoisation or bottom-up with a table.
Intermediate to Advanced10 cards · 6 qnot started
- Algorithms
Knapsack and grid dynamic programming: filling a table over items and capacities, or over the cells of a grid, and the loop orders that change the answer.
Intermediate to Advanced9 cards · 4 qnot started
- Algorithms
Sequence dynamic programming in algorithms: longest common subsequence, edit distance and longest increasing subsequence, each a table over prefixes.
Intermediate to Advanced9 cards · 4 qnot started
- Algorithms
Choosing between divide and conquer, dynamic programming, greedy and backtracking in algorithms, by how a problem's subproblems behave.
Intermediate to Advanced7 cards · 3 qnot started
Complexity Analysis
4 topics- Data Structures
Big O notation: how to describe the way a data structure operation's cost grows with its input, and why constants and smaller terms drop out.
Beginner to Intermediate8 cards · 5 qnot started
- Data Structures
Analysing complexity: reading the time and space a function needs from its loops, its recursion and the built-in calls hidden inside them.
Beginner to Intermediate8 cards · 5 qnot started
- Coding Interview Patterns
Solving an unseen problem: a fixed sequence of steps from clarifying the input to tracing the code, so a coding problem never starts from a blank page.
Intermediate to Advanced8 cards · 5 qnot started
- Coding Interview Patterns
Optimising a solution: finding the step that dominates a solution's cost and removing it with a standard move, and knowing when to stop.
Intermediate to Advanced8 cards · 4 qnot started
Two Pointer
2 topics- Coding Interview Patterns
Two pointers: walking a sorted array from both ends, or rewriting it in place with a read and a write pointer, and the precondition each needs.
Intermediate to Advanced8 cards · 4 qnot started
- Coding Interview Patterns
Fast and slow pointers: two pointers moving at different speeds that find a list's middle, detect a cycle and locate where the cycle starts.
Intermediate to Advanced8 cards · 4 qnot started
Greedy Algorithms
2 topics- Algorithms
Greedy algorithms: taking the locally best choice at every step, proving it with an exchange argument, and disproving it with a counterexample.
Intermediate to Advanced8 cards · 4 qnot started
- Algorithms
Choosing between divide and conquer, dynamic programming, greedy and backtracking in algorithms, by how a problem's subproblems behave.
Intermediate to Advanced7 cards · 3 qnot started
Binary Search
2 topics- Algorithms
Binary search: finding a value in a sorted array by halving the range at every step, with the invariant, the midpoint and the boundaries that make it correct.
Intermediate9 cards · 5 qnot started
- Coding Interview Patterns
Modified binary search: binary search on a condition instead of a value, on a rotated array, and over the possible answers to a problem.
Intermediate to Advanced8 cards · 4 qnot started
Backtracking
2 topics- Algorithms
Backtracking: building every candidate solution one choice at a time, undoing each choice, and pruning branches that cannot succeed.
Intermediate to Advanced9 cards · 4 qnot started
- Algorithms
Choosing between divide and conquer, dynamic programming, greedy and backtracking in algorithms, by how a problem's subproblems behave.
Intermediate to Advanced7 cards · 3 qnot started
Recursion
2 topics- Data Structures
Recursion: writing a function that calls itself on a smaller input, tracing it through the call stack, and replacing it with a loop when it runs too deep.
Beginner to Intermediate8 cards · 5 qnot started
- Coding Interview Patterns
Tree patterns: solving binary tree problems by passing values down or returning them up, level by level, or through both subtrees at once.
Intermediate to Advanced8 cards · 4 qnot started
Divide and Conquer
2 topics- Algorithms
Divide and conquer: designing an algorithm by splitting a problem, solving the parts recursively and combining them, then reading its cost from a recurrence.
Intermediate to Advanced8 cards · 4 qnot started
- Algorithms
Choosing between divide and conquer, dynamic programming, greedy and backtracking in algorithms, by how a problem's subproblems behave.
Intermediate to Advanced7 cards · 3 qnot started
Sliding Window
1 topic- Coding Interview Patterns
Sliding window: keeping a running answer for a contiguous run as it slides, with a fixed size or one that grows and shrinks, and the inputs that break it.
Intermediate to Advanced8 cards · 5 qnot started
In Algorithms itself
4 topics- Coding Interview Patterns
Prefix sums: precomputing running totals so any range sum is one subtraction, and counting the runs that hit a target with a hash map.
Intermediate to Advanced8 cards · 4 qnot started
- Coding Interview Patterns
Bit manipulation: reading and changing single bits with AND, OR, XOR and shifts, and where Python, Java and TypeScript give different answers.
Intermediate to Advanced8 cards · 4 qnot started
- Coding Interview Patterns
Choosing a pattern: reading the cues in a coding problem's wording to pick the pattern that fits, and telling a real cue from a keyword.
Intermediate to Advanced7 cards · 4 qnot started
- System Design
Caching: keeping copies of frequent reads close, deciding when they go stale, and the ways a cache can take a system down.
Beginner to Advanced9 cards · 8 qnot started