Tags

In-Place

In-Place

2 lessons
8 problems

in-place

Foundations

1 lesson

Space Complexity Fundamentals

Free
Beginner

35 min

1 prereq

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%

Foundations
Beginner
Free
Space Complexity
Big-O
Efficiency
In-Place
Fundamentals

Algorithms

1 lesson

Sorting (Elementary)

Free
Beginner

55 min

2 prereqs

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%

Algorithms
Sorting
Bubble Sort
Selection Sort
Insertion Sort
Stability
In-Place
Time Complexity
Beginner
Free

Practice Problems

8 problems

Merge Sorted Array

Free
Not Started
Easy

Merge two sorted arrays into one sorted array in-place, using the extra space at the end of the first array.

Arrays
Two Pointers
Sorting
In-Place
Beginner

259

8

Remove Duplicates from Sorted Array

Free
Not Started
Easy

Remove duplicates from a sorted array in-place so each element appears only once, and return the new length.

Arrays
Two Pointers
In-Place
Beginner

685

6

Remove Element

Free
Not Started
Easy

Remove all occurrences of a given value from an array in-place and return the new length.

Arrays
Two Pointers
In-Place
Beginner

936

26

Game of Life

Not Started
Medium

Implement Conway's Game of Life: compute the next state of a board in-place using state-encoding to avoid extra space.

Arrays
Matrix Algorithms
Matrix Traversal
Simulation
In-Place
Intermediate

489

5

Remove Duplicates from Sorted Array II

Not Started
Medium

Remove duplicates from a sorted array in-place so each element appears at most twice, using a two-pointer technique.

Arrays
Two Pointers
In-Place
Intermediate

878

23

Rotate Array

Not Started
Medium

Rotate an array to the right by k steps in-place using the reverse technique for O(1) extra space.

Arrays
Array Manipulation Patterns
In-Place
Intermediate

158

5

Rotate Image

Free
Not Started
Medium

Rotate an n x n 2D matrix by 90 degrees clockwise in-place, without allocating another matrix.

Arrays
Matrix Algorithms
Matrix Traversal
Rotate Matrix
In-Place
Intermediate

850

20

Set Matrix Zeroes

Free
Not Started
Medium

Given an m x n integer matrix, if an element is 0, set its entire row and column to 0 using constant extra space.

Arrays
Matrix Algorithms
Matrix Traversal
In-Place
Hash Map / Dictionary
Intermediate

861

14