In-Place
in-place
Foundations
Space Complexity Fundamentals
An algorithm that runs in `O(n)` time but allocates a fresh array of size `n^2` will not fit in memory long before it would have finished computing. Memory is finite, and many algorithms quietly trade it for speed; the only way to make that trade-off visible is to analyze space the same way you analyze time. **Space Complexity Fundamentals** extends the Big-O lens from operation counting to memory usage. You will see why we draw a line between auxiliary space (the extra storage an algorithm allocates) and total space (auxiliary plus the input itself), and you will classify common algorithms as `O(1)` constant, `O(n)` linear, or `O(n^2)` quadratic in space. You will meet the in-place vs out-of-place distinction that interviewers love to probe, and you will study a first space-time trade-off where caching results turns repeated work into stored data. In **Big-O Notation (Upper Bound)**, you learned to read complexity classes from loop structure and to recognize that `O(c * n)` collapses to `O(n)`. The same vocabulary and the same simplification rules apply here, but the resource being counted is bytes of allocated memory rather than units of work. Once you can reason about both axes at once, you will be ready for **Logarithms & Exponentiation**, where you will build the mathematical intuition behind `O(log n)`, the complexity class that powers binary search, balanced trees, and most efficient divide-and-conquer algorithms.
Not Started
0%
Algorithms
Sorting (Elementary)
Insertion sort is `O(n^2)` and quick sort is `O(n log n)`, yet V8 actually runs insertion sort on arrays shorter than ten elements because the constant factors are smaller. The takeaway is that elementary sorts are not just historical curiosities; they are the algorithms that real engines drop down to once an array is small enough. **Sorting (Elementary)** walks through bubble sort, selection sort, and insertion sort in detail. For each, you will trace the pass-by-pass behavior on a small input, count comparisons and swaps, and analyze worst, best, and average time complexity. Along the way the lesson introduces the vocabulary that every later sorting topic relies on: passes, the growing sorted region, the loop invariant that proves correctness, in-place vs. extra-space sorts, and stability (whether equal keys keep their original relative order). In **Arrays & Strings**, you learned how arrays store and index data; sorting is the first time you will rearrange that storage in place. **Iteration Patterns on Arrays/Strings** trained you in nested loops and swaps, and these three sorts are essentially structured nested loops with a clear invariant. Up next, **Searching (Basics)** establishes the linear-search baseline whose `O(n)` cost is exactly what binary search will later cut down once your data is sorted.
Not Started
0%
Practice Problems
Merge Sorted Array
Merge two sorted arrays into one sorted array in-place, using the extra space at the end of the first array.
Remove Duplicates from Sorted Array
Remove duplicates from a sorted array in-place so each element appears only once, and return the new length.
Remove Element
Remove all occurrences of a given value from an array in-place and return the new length.
Game of Life
Implement Conway's Game of Life: compute the next state of a board in-place using state-encoding to avoid extra space.
Remove Duplicates from Sorted Array II
Remove duplicates from a sorted array in-place so each element appears at most twice, using a two-pointer technique.
Rotate Array
Rotate an array to the right by k steps in-place using the reverse technique for O(1) extra space.
Rotate Image
Rotate an n x n 2D matrix by 90 degrees clockwise in-place, without allocating another matrix.
Set Matrix Zeroes
Given an m x n integer matrix, if an element is 0, set its entire row and column to 0 using constant extra space.
