← All Topics
Arrays
— Simple English
68 lessons · Data Structures & Algorithms · Simple English · Beginner Friendly
01
Understanding the Memory Model
Understanding the Memory Model Before you learn about data structures like arrays, you need to know one simple thing fir…
02
Why Do We Need Arrays? The Problem With Using Many Variables
Why Do We Need Arrays? The Problem With Using Many Variables Before learning what an array is, it helps to first feel th…
03
Meet the Array: A Better Way to Store Many Values
Why We Need Something Better Than Variables Imagine you want to store the age of every student in a class. With plain va…
04
The Four Core Array Operations: Create, Access, Modify, and Traverse
The Four Core Array Operations Once you understand what an array is — a row of boxes that hold data — the next step is l…
05
How Arrays Really Work in Memory
How Arrays Really Work in Memory You already know what an array is and how it helps you store lots of data together. Now…
06
How an Array Finds Your Data: Address Calculation and Dereferencing
How an Array Finds Your Data We already know that an array keeps all its items side by side in memory. Now let's see the…
07
Why One-Dimensional Arrays Are Not Always Enough
Why One-Dimensional Arrays Are Not Always Enough So far you have learned about a simple kind of array — a single row of …
08
What Dimensions Mean for Arrays
What Dimensions Mean for Arrays Before we can solve harder array problems, we need to be clear about one small but impor…
09
Multidimensional Arrays: Arrays Inside Arrays
What Is a Multidimensional Array? A normal array stores a list of simple values side by side — like a row of boxes, each…
10
Operations on Multidimensional Arrays: Create, Access, Modify, and Traverse
Working With Multidimensional Arrays A multidimensional array is just an array whose items are themselves arrays. Think …
11
How Multidimensional Arrays Are Stored in Memory
How Multidimensional Arrays Are Stored in Memory You already know what a multidimensional array is and why it is useful …
12
How Row-Major Order Stores Multidimensional Arrays in Memory
Row-Major Order: Flattening an Array Into a Straight Line When you write a 2D array in your head, you picture a neat tab…
13
How a 3D Array Is Stored in Memory (Row-Major Order)
How a 3D Array Lives in Memory A computer's memory is just one long line of numbered storage slots. But a three-dimensio…
14
Row-Major Traversal of a Matrix
Row-Major Traversal of a Matrix A matrix is just a table of numbers. It has rows (going across, left to right) and colum…
15
Column-Major Order: Storing a Grid Column by Column
Column-Major Order: Storing a Grid Column by Column Computer memory is one long, straight line of boxes. But a 2D array …
16
Column-Major Order with a 3D Array: How the Computer Finds Each Element
Storing a 3D Array in Memory (Column-Major Order) A computer's memory is really just one long line of numbered boxes, on…
17
Column-Major Traversal of a Matrix
Column-Major Traversal of a Matrix A matrix is just a table of numbers arranged in rows and columns. Think of it like a …
18
The Two-Pointer Pattern: Scanning an Array From Both Ends
The Two-Pointer Pattern When you work with an array, you usually find what you need in one of two ways: either you alrea…
19
Spotting When You Can Directly Use the Two-Pointer Technique (Reversing an Array In-Place)
When Can You Reach Straight for Two Pointers? The two-pointer technique is a powerful trick, but it does not fit every p…
20
Reversing an Array In Place by Swapping From Both Ends
Reversing an Array By Swapping From Both Ends Imagine you have a row of letters lined up in boxes, like this: [a, e, i, …
21
Checking if a String is a Palindrome
What is a Palindrome? A string is just a piece of text — a row of characters like letters, numbers, or symbols. A palind…
22
Reverse the Vowels in a String
Reverse the Vowels in a String In this lesson we solve a classic and very common interview problem. The idea is simple, …
23
Reverse the Letters in Each Word
Reverse the Letters in Each Word This problem asks you to take a sentence and flip the letters inside every word — but k…
24
Reverse Segments: Flipping the First k Characters of Every 2k Block
Reverse Segments This is a string puzzle. You are given a piece of text called s and a number called k. Your job is to w…
25
Reverse the Order of Words in a String
Reversing Word Order in a String Imagine you have a sentence, and your task is to keep every word the same, but flip the…
26
Two-Pointer Reduction: Turning a Hard Problem Into an Easy One
Two-Pointer Reduction: Turning a Hard Problem Into an Easy One Sometimes you meet a problem that does not look like a tw…
27
Two Sum: Finding a Pair That Adds Up to a Target
The Two Sum Problem Imagine you have a list of numbers, and someone hands you one special number called the target. Your…
28
Target Limited Two Sum: Finding the Best Pair Below a Limit
Target Limited Two Sum Let's solve a classic problem about working with arrays. An array is just a list of numbers store…
29
Duplicate-Aware Two Sum: Finding All Unique Pairs
Duplicate-Aware Two Sum Imagine you have a row of numbered cards laid out on a table, and a friend gives you a "magic nu…
30
Largest Container: Finding Two Walls That Hold the Most Water
Largest Container Imagine a row of vertical walls standing on the ground. Each wall has a certain height. If you pick an…
31
Spotting a Two-Pointer Subproblem: Rotating an Array Left
Spotting a Two-Pointer Subproblem Some problems do not look like two-pointer problems at first. But if you break them in…
32
Rotating an Array to the Right by k Steps
Rotating an Array to the Right by k Steps Imagine you have a row of numbered boxes lined up on a shelf. "Rotating to the…
33
Three Sum: Finding All Triplets That Add Up to Zero
Three Sum: Finding Triplets That Add Up to Zero Imagine you have a list of numbers, and someone asks you a simple questi…
34
Approximate Three Sum: Finding Three Numbers Closest to a Target
Approximate Three Sum Imagine you have a bag of numbers. Someone gives you a target number, and asks you a question: "Pi…
35
The Four Sum Problem: Finding Groups of Four Numbers That Add Up to a Target
The Four Sum Problem Imagine you have a row of numbers and a special "goal" number. Your job is to find every group of f…
36
Simultaneous Traversal: Walking Through Two Arrays at the Same Time
Simultaneous Traversal: Walking Through Two Arrays at Once When you have a single array, going through it is simple: you…
37
The Simultaneous Traversal Pattern: Checking if One Array Is a Subsequence of Another
What "simultaneous traversal" means Imagine you have two lists and you want to walk through both of them at the same tim…
38
Checking if One String is a Subsequence of Another
What is a Subsequence? Imagine you have a word, and you start crossing out some of its letters. You are not allowed to m…
39
Merging Two Sorted Arrays Into One
Merging Two Sorted Arrays Into One Imagine you have two lists of numbers. Both lists are already neatly sorted from smal…
40
Finding the Unique Intersection of Two Arrays
The Problem: What Do Two Lists Have in Common? Imagine you have two shopping lists. The first list has the items you bou…
41
Finding the Intersection of Two Arrays (With Repeats)
Finding the Intersection of Two Arrays Imagine you have two shopping lists. You want to find only the items that appear …
42
The Fixed-Sized Sliding Window Technique
The Fixed-Sized Sliding Window Technique Imagine you have a long row of numbers and you want to answer a question about …
43
The Fixed-Size Sliding Window Pattern
What is a fixed-size sliding window? Imagine you have a long row of numbers and you must look at exactly 4 of them at a …
44
Finding the Smallest Sum of a Fixed-Size Window in an Array
Smallest Sum Among All Subarrays of Size k Imagine you have a row of numbers, and you want to look at them through a sma…
45
Maximum Number of 1s in a Window of Size k
Finding the Most 1s in a Window of Size k Imagine you have a row of light switches. Each switch is either on (written as…
46
Counting Negative Numbers in Every Window of Size k
Counting Negatives in Each Sliding Window Imagine you have a list of numbers, and you want to look at them through a sma…
47
Counting Even and Odd Numbers in Every Window of Size k
The Problem You are given a list of whole numbers, called arr, and a positive number k. Your job is to look at every blo…
48
The Variable-Sized Sliding Window Pattern
The Variable-Sized Sliding Window Pattern Sometimes a problem asks you to look at subarrays of an array. A subarray is j…
49
The Variable-Sized Sliding Window Pattern (Maximum Sum Subarray)
The Variable-Sized Sliding Window Pattern Some problems ask you to look at every possible piece of an array and combine …
50
Finding the Longest Run of 1's in a Binary Array
Counting Consecutive 1's A binary array is just a list of numbers where every value is either 0 or 1. Nothing else is al…
51
Counting Subarrays With a Product Less Than k
The Problem: "Product Conundrum" You are given an array of positive whole numbers called arr, and one more number called…
52
Maximum Subarray Sum
Maximum Subarray Sum This is a classic and very famous problem in programming. Once you understand it, you will start se…
53
Maximum Consecutive 1's When You Can Flip K Zeros
Maximum Consecutive 1's When You Can Flip K Zeros Imagine you have a row of light switches, and each switch is either on…
54
The Line Sweep Technique for Intervals
The Line Sweep Technique for Intervals What is an interval? Many array problems give you data that is not just single nu…
55
Merging Overlapping Intervals with the Line Sweep Technique
What "merging intervals" means An interval is just a small range that has a start and an end. We can write it as a pair …
56
The Interval Merging Pattern: Combining Overlapping Ranges
What is an interval? An interval is just a range with a start and an end. For example, [3, 6] means "from 3 to 6". You c…
57
Can a Person Attend All Their Meetings? (The Overlapping Intervals Problem)
Can a Person Attend All Their Meetings? Imagine you have a calendar full of meetings. Each meeting has a start time and …
58
Merging Overlapping Intervals
Merging Overlapping Intervals Imagine you have a list of time slots. Maybe one meeting runs from 1 PM to 4 PM, another f…
59
Finding Employee Free Time: Merging Meeting Intervals
Finding the Free Time Between Meetings Imagine a company where many employees have meetings throughout the day. Each mee…
60
Insert Interval: Adding a Range and Merging Overlaps
Insert Interval What is an interval? An interval is just a pair of numbers that marks a start and an end on a number lin…
61
The Line Sweep Technique on Points
The Line Sweep Technique on Points Imagine a line of dominoes standing on a long ruler. You walk past them from the left…
62
Finding the Maximum Overlap with the Line Sweep Technique
Finding the Maximum Number of Overlapping Intervals Imagine you run a small meeting room. People book it for time slots …
63
The Maximum Overlap Pattern (Minimum Meeting Rooms with Line Sweep)
The Maximum Overlap Pattern Some problems give you a list of intervals — pairs of numbers like a start and an end. An in…
64
Minimum Meeting Rooms: How Many Rooms Do You Really Need?
Minimum Meeting Rooms Imagine you run an office. Many meetings are booked for the day. Each meeting has a start time and…
65
Remove Intervals: Making Intervals Non-Overlapping
Remove Intervals: Making Intervals Non-Overlapping Imagine you are booking meeting rooms. Each meeting has a start time …
66
Finding the Busiest Time Slot Among Overlapping Meetings
The Busiest Interval Problem Imagine you run a meeting room booking system. People schedule meetings, and each meeting h…
67
Finding the Busiest Interval: Peak Resource Requirement
Finding the Busiest Interval Imagine you run a small data center. Many jobs want to run, and each job needs a certain am…
68
Designing a Dynamic Array
Designing a Dynamic Array Imagine you have a row of boxes to store numbers. A normal array in many languages has a fixed…