Free course · 61 topics · about 90 hours
Data Structures and Algorithms (DSA) for interviews
Ask or find help in Data Structures and Algorithms (DSA) for interviews
Type a question or a word. You get the topics, explanations, meanings and quiz answers that cover it, and each result opens at the right place.
Try:
Your timeline: start to finish
About 13 weeks at 1 hour a day (90 study days) · 0/12 modules done
Beginner: foundationsWeeks 1–5
- Thinking in Big-OWeek 1
5 topics · 2.6 h of lessons · ~6.2 h with practice · you are here
- Arrays and stringsWeeks 1–2
5 topics · 3 h of lessons · ~7.2 h with practice
5 topics · 3 h of lessons · ~7.2 h with practice
📝 Module 3 exam: Hashing, two pointers and sliding window · 14 questions
- Stacks, queues and linked listsWeeks 3–5
5 topics · 3.2 h of lessons · ~7.5 h with practice
📝 Module 4 exam: Stacks, queues and linked lists · 14 questions
Intermediate: core algorithmsWeeks 5–9
- Recursion and backtrackingWeeks 5–6
5 topics · 3.1 h of lessons · ~7.4 h with practice
- Sorting and searchingWeeks 6–7
5 topics · 3.2 h of lessons · ~7.5 h with practice
- Trees and binary search treesWeeks 7–8
5 topics · 3.1 h of lessons · ~7.4 h with practice
📝 Module 7 exam: Trees and binary search trees · 15 questions
- Heaps and greedy algorithmsWeeks 8–9
5 topics · 3.3 h of lessons · ~7.7 h with practice
Expert: advanced patterns and interviewsWeeks 9–13
- GraphsWeeks 9–10
6 topics · 3.8 h of lessons · ~8.8 h with practice
- Tries, union-find and bit manipulationWeeks 10–11
5 topics · 2.9 h of lessons · ~7 h with practice
- Dynamic programmingWeeks 11–12
5 topics · 3.3 h of lessons · ~7.7 h with practice
- Interview strategy and mock problemsWeeks 12–13
5 topics · 2.9 h of lessons · ~7 h with practice
📝 Module 12 exam: Interview strategy and mock problems · 14 questions
Final exam: Data Structures and AlgorithmsWeek 13
38 questions · 90 min · pass 70% for the certificate
Weeks count lessons, practice, quizzes and exams (about 90 hours in all), studying every day. Go faster or slower as you like: your place is kept on this device.
0/61 topics done
Beginner: foundations
Weeks 1–6. Big-O, arrays, strings, hashing, two pointers, sliding windows, stacks, queues and linked lists. After this level you can solve most "easy" interview problems and explain their cost.
1Thinking in Big-O0/5 topics▼
What data structures and algorithms are, how to learn them, and how to measure code with Big-O: time and space complexity, best and worst cases, halving loops, recursion trees and the true cost of Python and JavaScript built-ins. After this module you can look at a piece of code, state its time and space complexity, and rewrite an O(n²) idea as O(n) with a set or a dictionary.
- What DSA is, and how to learn itA data structure is a way of storing data so that the jobs you need are quick. An algorithm is a clear, step-by-step method to solve a problem. Companies test DSA to see how you think through a new problem, not what you have memorised. This course takes about 18 weeks at one hour a day, with extra practice on free problem sites.20 min
- Big-O time complexityBig-O describes how the number of steps your code takes grows as the input grows. You drop constants and smaller terms, so 3n + 5 steps is O(n). Loops one after another add up; loops inside loops multiply. Knowing the common classes, from O(1) to O(n!), tells you before you run anything whether an idea is fast enough.35 min
- Space complexity and amortised costSpace complexity is how much EXTRA memory your code needs as the input grows. In-place code changes the input and uses only O(1) extra memory. Recursion uses memory too, one frame per waiting call. Appending to a Python list is O(1) amortised: now and then the list must grow and copy, but averaged over many appends each one is cheap.30 min
- Best, average and worst case; analysing loops and recursionThe same code can be fast on one input and slow on another, so we talk about best, average and worst cases; interviews usually mean the worst case. A loop that halves or doubles its counter runs O(log n) times. For recursion, draw a recursion tree: add up the work on each level and count the levels.35 min
- The real cost of Python and JavaScript built-insA single line of Python or JavaScript can hide a whole loop. Reading list[i] is O(1), but list.insert(0, x), list.pop(0) and x in list are O(n). Dicts, sets, Maps and Sets give O(1) lookups on average. Building a string with += in a loop can be O(n²), so collect the parts in a list and join them once.35 min
2Arrays and strings0/5 topics▼
The two structures behind most interview problems: arrays (traversal, in-place updates, rotation, prefix sums, difference arrays, Kadane's maximum subarray and 2-D grids) and strings (immutability, palindromes, anagrams, building strings and Unicode). After this module you can solve the common easy and medium array and string problems in O(n) time and explain the cost of each step.
- Arrays: traversal and in-place updatesAn array keeps items side by side in memory, so reading any position is O(1), but inserting or deleting in the middle shifts the rest, O(n). Most array problems are solved by walking through the array in a smart order. Reversing, rotating by k and moving zeros to the end can all be done in place with O(1) extra space.35 min
- Prefix sums and difference arraysA prefix sum array stores the running totals of a list, so the sum of any range is one subtraction: O(1) per query after O(n) setup. A difference array does the reverse job: it applies many "add v to every item from l to r" updates in O(1) each, and one pass at the end gives the final values.35 min
- Strings: building, comparing and countingA string is a sequence of characters that cannot be changed after it is made (it is immutable). Most string problems use the same tools as arrays: two pointers from both ends (palindromes), counting characters (anagrams), and building the answer in a list and joining it once. ord() and chr() convert between characters and numbers.35 min
- Maximum subarray: Kadane's algorithmThe maximum subarray problem asks for the largest sum of a run of neighbouring numbers. Trying every run is O(n²). Kadane's algorithm walks once and keeps the best sum of a run that ENDS at the current position: either extend the previous run or start fresh. It is O(n) time, O(1) space, and its cousin solves the "buy and sell a stock once" problem.35 min
- 2-D arrays (matrices)A matrix is a grid of rows and columns, stored in Python as a list of lists: grid[row][col]. You walk it row by row, swap rows and columns to transpose it, rotate it 90° clockwise with a transpose plus reversing rows, and read it in spiral order with four shrinking boundaries. A matrix sorted along rows and columns can be searched in O(m + n) from the top-right corner.40 min
3Hashing, two pointers and sliding window0/5 topics▼
Three patterns that solve a large share of interview problems in O(n): hash maps and sets (lookups, counting, grouping, prefix sums with a map), two pointers (pairs in sorted arrays, in-place filtering, merging, 3-sum) and sliding windows (fixed size and variable size). After this module you can spot which pattern fits a problem, replace O(n²) pair checks with O(n) passes, and explain the time and space cost and the edge cases of each.
- Hash maps and hash setsA hash map stores key → value pairs and a hash set stores keys only. A hash function turns each key into a number that points almost straight at its slot, so insert, lookup and delete are O(1) on average (O(n) in the rare worst case). Python's dict and set and JavaScript's Map and Set are hash tables, and they turn many O(n²) "have I seen this?" solutions into O(n).35 min
- Counting and grouping with hashingA frequency map counts how often each item appears, in one O(n) pass. The same idea groups items that share a key (anagrams share their sorted letters), ranks the top k most frequent items with a clear tie rule, and, together with prefix sums, counts the subarrays that add up to k in O(n), even with negative numbers.35 min
- Two pointersTwo pointers are two index variables that move through an array in a planned way, so each step rules out many possibilities. Pointers at opposite ends of a SORTED array find pairs with a target sum and the container with most water in O(n). A slow and a fast pointer moving the same way filter an array in place. Sorting plus two pointers solves 3-sum in O(n²).40 min
- Sliding window: fixed sizeA fixed-size window is a run of exactly k neighbouring items. Recomputing every window costs O(n × k). Sliding it is O(n): when the window moves one step, add the item that enters and remove the item that leaves. The same trick gives the best k-day sales total, moving averages, and the count of windows that are anagrams of a word.30 min
- Sliding window: variable sizeWhen the question asks for the longest or shortest run that obeys a rule, the window grows and shrinks. Move the right edge forward one item at a time, and while the window breaks the rule, move the left edge forward. Each edge moves at most n times, so it is O(n). It solves the longest substring without repeats, the shortest run reaching a target sum (positive numbers only) and the longest run with at most k distinct characters.40 min
4Stacks, queues and linked lists0/5 topics▼
The linear structures behind undo buttons, rate limiters, playlists and breadth-first search: stacks (brackets, postfix expressions, min-stack), queues and deques (deque, circular queues, a JavaScript queue without shift), monotonic stacks and deques (next greater element, sliding window maximum), and linked lists (insert, delete, reverse, fast and slow pointers, cycle detection, merging). After this module you can choose between a list, a deque and a linked list for a job, say what each operation costs, and write the classic stack, queue and linked-list interview solutions in O(n) time.
- StacksA stack adds and removes items at one end, the top: the last item in is the first one out (LIFO). With a Python list, push (append), pop and peek (stack[-1]) are all O(1). Stacks check matching brackets, evaluate postfix expressions, power undo and the back button, and a min-stack can report its smallest item in O(1).35 min
- Queues and dequesA queue adds at the back and removes from the front: first in, first out (FIFO). A Python list is a poor queue because pop(0) shifts every item, O(n). collections.deque adds and removes at both ends in O(1). A circular queue reuses one fixed array by wrapping its indexes with % capacity, and in JavaScript you avoid the O(n) shift() by moving a head index.35 min
- Monotonic stacks and queuesA monotonic stack keeps its items in sorted order by popping everything that would break the order before each push. The popped items have just found their "next greater" (or smaller) element, so questions like the next warmer day or a stock's span are answered for every item in O(n). A monotonic deque does the same for windows: the maximum of every window of size k in O(n).40 min
- Linked listsA linked list is a chain of nodes, each holding a value and a pointer to the next node. Adding or removing at the head is O(1), but there is no random access: reaching position i means walking i steps. Singly linked lists point forwards only; doubly linked lists also point back. Reversing a list is the classic exercise: three pointers iteratively, or recursion with O(n) stack space.40 min
- Fast and slow pointers and merging listsTwo pointers walking a linked list at different speeds, or with a fixed gap, answer questions in one pass with O(1) extra space: the middle node, whether the list has a cycle (Floyd's tortoise and hare), where the cycle starts, and the n-th node from the end. A dummy node makes merging two sorted lists short and safe, and the same tools check whether a list is a palindrome.40 min
Intermediate: core algorithms
Weeks 7–12. Recursion, backtracking, sorting, binary search, trees, heaps and greedy algorithms. After this level you can solve many "medium" problems and choose between brute force and a faster idea.
1Recursion and backtracking0/5 topics▼
How functions that call themselves work (base cases, the call stack, Python's recursion limit), how divide and conquer halves a problem (fast power, recursive binary search, merging), how backtracking lists every subset, permutation and combination with choose-explore-un-choose and pruning, and how memoization turns exponential recursion into linear time. After this module you can write a correct recursive solution, trace it on the call stack, state its time and stack space, and solve the classic subsets, permutations, combination sum, parentheses and N-Queens problems.
- Recursion: functions that call themselvesA recursive function solves a problem by calling itself on a smaller piece of the same problem. Every recursive function needs a base case (a size so small the answer is known) and a recursive case (shrink the problem and call again). Each waiting call sits on the call stack, so recursion uses O(depth) memory, and Python stops at about 1,000 levels with a RecursionError.35 min
- Divide and conquerDivide and conquer splits a problem into smaller parts of the same kind (usually halves), solves each part recursively, and combines the answers. Because the size halves at each level, the recursion is only about log₂ n deep. Fast power, recursive binary search and merge sort all follow this pattern.35 min
- Backtracking: subsets and permutationsBacktracking builds every possible answer one choice at a time: choose an option, explore everything that follows from it, then undo the choice and try the next one. The choices form a decision tree. Generating all subsets visits 2ⁿ leaves and all permutations n! leaves, so backtracking is for small n (about 20 for subsets, about 10 for permutations).40 min
- Backtracking with pruningPruning means cutting off a branch of the decision tree as soon as you know it cannot lead to a valid answer, instead of building it to the end and then rejecting it. A simple check at each step (the sum is already too big, there are more closing brackets than opening ones, two queens attack each other) can make backtracking thousands of times faster. Combination sum, phone letter combinations, balanced parentheses, N-Queens and Sudoku are the classic examples.40 min
- Memoization: remembering answersSome recursive functions solve the same smaller problem again and again. Memoization stores each answer the first time it is computed (in a dictionary, or with functools.cache) and returns the stored answer on later calls. Naive Fibonacci drops from O(2ⁿ) to O(n). This is top-down dynamic programming, which Module 11 builds on.35 min
2Sorting and searching0/5 topics▼
How sorting works, from the simple O(n²) sorts (bubble, selection, insertion) and stability to merge sort and quick sort, then how to sort in real code with keys, comparators, Timsort and counting sort, and how to avoid JavaScript's string-sorting trap. The second half is binary search: the exact loop, lower and upper bounds, bisect, rotated arrays, and binary search on the answer. After this module you can choose and explain the right sort, write merge sort, quick sort and a bug-free binary search, and solve "minimum capacity" style problems in O(n log range).
- Simple sorts: bubble, selection and insertionBubble sort swaps neighbours that are out of order, selection sort picks the smallest remaining item each round, and insertion sort slides each new item back into its place like sorting playing cards. All three take O(n²) time and O(1) extra space. Insertion sort is fast on nearly sorted data, and bubble and insertion sort are stable: equal items keep their original order.35 min
- Merge sort and quick sortMerge sort splits the list in half, sorts each half and merges them: always O(n log n), stable, but it needs O(n) extra memory. Quick sort picks a pivot, moves smaller items to its left and bigger ones to its right, and sorts each side: O(n log n) on average and in place, but O(n²) in the worst case when pivots are chosen badly. Random or median-of-three pivots avoid that in practice.40 min
- Sorting in real code: keys, comparators, counting sortIn real code you rarely write a sort; you tell the built-in sort what to compare. Python's sorted() and list.sort() take a key function and reverse=True, sort by several fields with a tuple key, and are stable (they use Timsort). functools.cmp_to_key handles custom pairwise rules. For small integer ranges, counting sort runs in O(n + k). In JavaScript, always pass a comparator: [10, 9, 1].sort() sorts as strings.35 min
- Binary searchBinary search finds a value in a SORTED list by checking the middle and throwing away the half that cannot contain it, so it needs only about log₂ n steps: 20 steps for a million items. The idea is simple; the details (lo, hi, mid and the loop condition) are where bugs hide. Lower bound and upper bound find the first and last positions of a value, Python's bisect module gives them for free, and a small twist searches a rotated sorted array.40 min
- Binary search on the answerSometimes the list is not what you search; the ANSWER is. If the answer is a number in a known range and a check "is x enough?" is monotonic (false, false, …, true, true), binary search finds the smallest x that works in O(log range) checks. Koko eating bananas, shipping packages within D days, integer square root and allocating book pages are the classic examples.40 min
3Trees and binary search trees0/5 topics▼
Trees model hierarchies such as folders, org charts and the HTML DOM. This module covers tree words and shapes, DFS and BFS traversals (recursive and iterative), the recursive patterns behind height, diameter, balance and path sums, binary search trees (search, insert, delete, validate, k-th smallest), the lowest common ancestor, serialisation and the balanced trees used in libraries and databases. After this module you can solve the common tree interview problems in O(n) and explain why a balanced tree keeps operations at O(log n).
- Trees: words and shapesA tree is a set of nodes joined by edges, with one node at the top (the root) and no loops. Each node can have children, and nodes without children are leaves. In a binary tree every node has at most two children, called left and right. You store a binary tree either as linked nodes (a TreeNode class) or, when it is complete, in a plain array where the children of index i sit at 2i + 1 and 2i + 2.30 min
- Traversals: DFS and BFSA traversal visits every node once in a fixed order. Depth-first search (DFS) goes down one branch before the next and comes in three orders: preorder (node, left, right), inorder (left, node, right) and postorder (left, right, node). Breadth-first search (BFS), also called level order, visits the tree level by level using a queue. All of them are O(n) time.35 min
- Recursive tree patternsMost tree problems are solved by one recursive shape: ask the left and right subtrees for an answer, combine them at the node, and return the result upward. With it you can find the height and the diameter, check whether a tree is balanced in O(n), test a root-to-leaf path sum, mirror a tree, and compare two trees.40 min
- Binary search treesA binary search tree (BST) keeps every value in a node's left subtree smaller than the node and every value in its right subtree larger. That rule lets search, insert and delete walk one path, O(h). An inorder traversal of a BST gives the values in sorted order, which is the key to validating a BST, finding the k-th smallest value and building a balanced BST from a sorted array.40 min
- Lowest common ancestor, serialisation and balanced treesThe lowest common ancestor (LCA) of two nodes is the deepest node that has both of them below it (a node counts as below itself). In a BST you find it by walking down until the two values split; in any binary tree a postorder search finds it in O(n). Serialising turns a tree into a string (preorder with markers for empty children) so it can be saved or sent and rebuilt. Self-balancing trees such as AVL and red-black trees keep the height O(log n); B-trees do the same job for databases on disk.40 min
4Heaps and greedy algorithms0/5 topics▼
Heaps give you the best item fast: priority queues, top k, merging sorted lists and running medians. Greedy algorithms take the best choice at each step: activity selection, change making, interval problems (merging, meeting rooms, railway platforms) and classics such as the jump game, gas station, rescue boats, the fractional knapsack and Huffman coding. After this module you can use Python's heapq confidently, choose a greedy rule and argue why it is correct (or find the counterexample that shows it is not).
- Heaps and priority queuesA priority queue always hands out the most important item first, not the oldest. A binary heap is the usual way to build one: a complete binary tree stored in an array, where every parent is smaller than (or equal to) its children. Push and pop cost O(log n), looking at the smallest item costs O(1), and turning a whole list into a heap costs only O(n). Python's heapq module gives you a min-heap on a plain list.40 min
- Heap patterns: top-k and streamsHeaps shine when you only need the best few items, or when data keeps arriving. To keep the k largest values, use a MIN-heap of size k: its root is the weakest of the current top k, so you can drop it cheaply, for O(n log k) in total. The same idea finds the k-th largest value, the k closest points and the most frequent items. A heap of "front items" merges k sorted lists, and two heaps together track the running median of a stream.40 min
- Greedy algorithms: the ideaA greedy algorithm builds an answer step by step and, at each step, takes the choice that looks best right now, never going back. It is fast and simple, but it is only correct when the problem has the greedy-choice property. You show that with an exchange argument. Picking the most meetings for one room (sort by end time) and giving change with Indian notes and coins are classic cases where greedy works; the coin system {1, 3, 4} shows where it fails.35 min
- Interval problemsAn interval is a pair (start, end), like a meeting, a booking or a train's stay at a station. Most interval problems start by sorting, by start time to merge overlaps or by end time to keep as many as possible. Then one pass, sometimes with a heap of end times, answers questions such as "merge these slots", "how many rooms do we need?" and "how many platforms does this station need?".40 min
- More greedy classicsA handful of greedy problems come up again and again: the jump game (track the farthest reachable index), the gas station circuit (restart after a deficit), boats to save people (pair the heaviest with the lightest), and the fractional knapsack (take the best value per kilo first). Huffman coding builds short codes for frequent symbols by always merging the two rarest. Knowing why each greedy rule works, and why the 0/1 knapsack needs dynamic programming instead, is the real lesson.40 min
Expert: advanced patterns and interviews
Weeks 13–18. Graphs, tries, union-find, bits, dynamic programming and interview strategy. After this level you can handle graph and DP rounds and run a calm, structured coding interview.
1Graphs0/6 topics▼
Graphs model metro maps, friend networks, flight routes and dependencies. This module covers how to store a graph, breadth-first and depth-first search, topological sort, shortest paths with Dijkstra (and when to use Bellman-Ford, 0-1 BFS or Floyd–Warshall), and the patterns that hide graphs inside grid, word and scheduling problems. After this module you can turn a problem into vertices and edges, pick the right traversal, and code BFS, DFS, Kahn's algorithm and Dijkstra with their O(V + E) and O((V + E) log V) costs.
- Graphs: vertices, edges and how to store themA graph is a set of things (vertices) and the connections between them (edges). Edges can have a direction and a weight, and a graph can have cycles and several separate pieces. You store a graph as an edge list, an adjacency matrix or, most often in interviews, an adjacency list, which takes O(V + E) space.30 min
- Breadth-first search (BFS)Breadth-first search explores a graph in layers: first the start, then everything one edge away, then everything two edges away. It uses a queue and a visited set, runs in O(V + E), and gives the shortest path when every edge counts the same, such as the fewest metro stops. Grids and "many starting points" problems are BFS too.40 min
- Depth-first search (DFS)Depth-first search follows one path as far as it can, then backs up and tries the next branch. It uses recursion or an explicit stack, runs in O(V + E), and is the natural tool for counting connected components and islands, checking whether a path exists, and finding cycles. Python's recursion limit (1000 by default) makes an explicit stack safer on big graphs.40 min
- Topological sortA topological order lists the vertices of a directed graph so that every edge u → v has u before v, like doing prerequisites before the courses that need them. It exists only when the graph has no cycle (a DAG). Kahn's algorithm repeatedly takes vertices with in-degree 0 using a queue; if the output is shorter than n, there is a cycle. Both Kahn and the DFS method run in O(V + E).35 min
- Shortest paths: Dijkstra and friendsWhen edges have weights such as minutes or rupees, the path with the fewest edges is not always the cheapest, so BFS is not enough. Dijkstra's algorithm always expands the closest unfinished vertex using a min-heap and runs in O((V + E) log V), but it needs non-negative weights. Bellman-Ford handles negative edges, 0-1 BFS handles weights of 0 and 1, and Floyd–Warshall finds all pairs on small graphs.40 min
- Graph problem patternsMany interview problems are graph problems in disguise: cells in a grid, words that differ by one letter, tasks with dependencies, or people with conflicts. Once you name the vertices and the edges, a known tool usually fits: two-colouring for "split into two groups", flood fill for "paint a connected area", BFS on an implicit graph for word ladder, and a dictionary from old to new vertices for cloning a graph.40 min
2Tries, union-find and bit manipulation0/5 topics▼
Three specialised tools that make some interview problems easy: tries for prefix search and autocomplete, union-find for groups that merge (with Kruskal's and Prim's minimum spanning trees as the main application), and bit manipulation, from AND, OR, XOR and shifts to the classic XOR and bitmask tricks. After this module you can build a trie and a DSU from scratch, find a minimum spanning tree, and use bits to test, set and count flags and to list subsets, while knowing how Python's unbounded integers differ from 32-bit languages.
- Tries (prefix trees)A trie (prefix tree) stores words letter by letter: each node has a map of children and a flag that marks the end of a word. Insert, search and "does any word start with this prefix?" all take O(L) time for a word of length L, no matter how many words are stored. Tries power search-box suggestions and contact search, at the cost of extra memory.35 min
- Union-find (disjoint set union)Union-find (also called disjoint set union, DSU) keeps items in groups that can only merge. Each item points to a parent, and the root of the chain names the group. find follows parents to the root, and union joins two roots. With path compression and union by size, each operation is almost O(1) amortised, which makes DSU ideal for "are these connected?" questions as edges arrive.35 min
- Minimum spanning treesA minimum spanning tree (MST) connects all the vertices of a weighted, undirected graph using the cheapest possible set of edges, with no cycles: exactly V − 1 edges. Kruskal's algorithm sorts the edges and adds each one that joins two different union-find groups. Prim's algorithm grows one tree from a start vertex using a heap. Both run in about O(E log E).35 min
- Bits: AND, OR, XOR and shiftsEvery integer is stored as bits, 0s and 1s. Bitwise operators work on those bits directly: & (AND), | (OR), ^ (XOR), ~ (NOT), << and >> (shifts). With them you can check, set, clear or toggle one bit, test for a power of two with n & (n − 1), and count set bits. Python integers have no fixed size, so negative numbers and ~ behave differently from 32-bit languages such as Java, C++ and JavaScript.35 min
- Bit tricks in interviewsA handful of bit tricks come up again and again. XOR cancels pairs, so it finds the single number in a list of pairs and the missing number in 0..n with O(1) extra space. Counting from 0 to 2ⁿ − 1 and reading the bits of each number lists every subset of n items. The Hamming distance of two numbers is the popcount of their XOR.35 min
3Dynamic programming0/5 topics▼
Dynamic programming from zero: overlapping subproblems, memoisation and tables, a four-step recipe, 1-D classics (house robber, coin change, decode ways, word break), 2-D grids and strings (unique paths, LCS, edit distance), knapsack problems, LIS, maximum product, palindromes, and how to recognise and debug DP. After this module you can spot a DP problem, define its state and recurrence, fill the table in the right order, save space, and explain the time and space cost.
- Dynamic programming: the ideaDynamic programming (DP) solves a big problem by solving smaller versions of it once each and storing the answers. It works when the same small problems come up again and again (overlapping subproblems) and the best answer is built from the best answers to smaller problems (optimal substructure). You can fill the answers from the top with memoisation, or from the bottom with a table, and often shrink the table to two variables.35 min
- 1-D DP classicsMany interview DP problems use a one-dimensional table: dp[i] is the answer for the first i items, or for the amount i. House robber chooses between taking or skipping each house. Coin change finds the fewest coins for an amount, or counts the ways to make it, where the order of the two loops decides whether you count combinations or orderings. Decode ways and word break build a string answer one piece at a time.40 min
- 2-D DP on grids and stringsSome problems need two numbers to describe a smaller problem: a cell (row, column) in a grid, or a position in each of two strings. Then the DP table is a grid, and each cell is built from its neighbours above, to the left, or diagonally. Unique paths, minimum path sum, longest common subsequence and edit distance all follow this shape, and you can walk back through the table to rebuild the actual answer.40 min
- Knapsack problemsIn the 0/1 knapsack problem you choose items, each with a weight and a value, to fit in a bag of fixed capacity, and each item can be taken at most once. A 2-D table over (items, capacity) solves it, and a 1-D array works too if you loop the capacity DOWNWARDS. Looping upwards instead lets items repeat, which is exactly the unbounded knapsack. Subset sum, equal partition and target sum are knapsack problems in disguise.40 min
- More DP patterns and how to spot themA few more patterns cover most of the DP you will meet in interviews: the longest increasing subsequence (O(n²) DP, or O(n log n) with binary search), the maximum product subarray (track both the largest and the smallest), and palindromic substrings (expand around each centre). Interval DP and bitmask DP handle ranges and small sets. Learn the signals in a question that point to DP, and a checklist for debugging a table that gives wrong answers.40 min
4Interview strategy and mock problems0/5 topics▼
Putting the whole course to work in real interviews: recognising patterns from signals and constraints, a step plan for live coding rounds, edge cases and debugging under pressure, design-style problems (LRU cache, time-based store, rate limiter, O(1) random set), and a study plan with honest advice on the job hunt in India. After this module you can pick an approach from the question and its constraints, run a calm and structured interview, find your own bugs, design small fast classes, and follow a 12–16 week practice plan.
- Recognising the patternMost interview problems are new stories built on a small set of patterns you have already learnt in this course. Words in the question ("sorted", "subarray", "top k", "all combinations", "shortest", "number of ways") and the input size in the constraints point you to the right technique and the speed you need. Reading those signals first saves you from coding the wrong idea.35 min
- Running the coding interviewA coding interview checks how you think, not only whether your code runs. Follow a steady plan: restate the problem, clarify inputs and edge cases, work an example, state the brute force and its cost, improve it, agree on the approach, code cleanly, test, and give the complexity. Think aloud the whole time, and when you are stuck, shrink the problem or ask for a hint instead of going silent.35 min
- Testing, edge cases and debugging under pressureMost failed interview solutions are not wrong ideas but small bugs: an empty list, an off-by-one loop, a forgotten last window. A short edge-case checklist, a dry run with a table of variables, a few quick asserts and calm reading of error messages find these bugs before the interviewer does.35 min
- Mock problems: design-style data structuresSome interview questions ask you to design a small class with fast operations instead of writing one function. The classics are an LRU cache (get and put in O(1)), a hit counter or rate limiter, a time-based key-value store (binary search on timestamps), and a set with insert, delete and getRandom in O(1). The trick is to combine two simple structures so each covers the other's weak spot.40 min
- Your study plan and the job huntSteady practice beats last-minute cramming: about one hour a day for 12 to 16 weeks, pattern by pattern, with spaced revision and a notebook of your mistakes. Mock interviews with friends turn knowledge into calm performance. In India, product companies, service companies and startups hire in different ways and pay differently, so aim your preparation and your resume at the roles you want.30 min
🎓 Final exam and certificate
38 questions, 90 minutes, pass mark 70%. Pass it to get a certificate with your name.