← All Topics

Singly Linked Lists — Simple English

80 lessons · Data Structures & Algorithms · Simple English · Beginner Friendly

🔒Premium course. The first 3 lessons are free — subscribe to unlock the rest (one plan unlocks every premium course).View plans
01 Why Arrays Struggle: The Problem That Leads Us to Linked ListsFree Why Arrays Struggle: The Problem That Leads Us to Linked Lists Before learning about a linked list, it helps to first un… 02 The Singly Linked List: A Flexible Alternative to ArraysFree The Singly Linked List: A Flexible Alternative to Arrays Arrays are great, but they have a weak spot. An array needs one… 03 Defining a Node in a Singly Linked ListFree What is a Node? Think of a linked list like a treasure hunt. At each spot you find two things: a small piece of treasure… 04 The Structure of a Singly Linked List: Nodes, Head, and Tail🔒 The Structure of a Singly Linked List A linked list is just a chain of boxes. Each box is called a node, and the nodes a… 05 Operations on a Singly Linked List: Traversal, Insertion, and Deletion🔒 Operations on a Singly Linked List You already know two things: what a single node of a singly linked list looks like (a… 06 Boundary Nodes: Spotting the First and Last Node of a Linked List🔒 Boundary Nodes in a Singly Linked List Before we solve this, let's make sure we know what a linked list is. Imagine a tr… 07 How to Walk Through Arrays and Singly Linked Lists (Traversal)🔒 Traversal: Visiting Every Item, One by One "Traversal" just means going through a data structure and looking at each ite… 08 Walking Through a Linked List: Printing Every Value🔒 Walking Through a Linked List: Printing Every Value Imagine a treasure hunt where each clue points you to the next clue.… 09 Searching for a Node in a Singly Linked List🔒 Searching for a Value in a Linked List A singly linked list is a chain of small boxes called nodes. Each node holds two … 10 Finding the Length of a Singly Linked List🔒 Finding the Length of a Singly Linked List A linked list is a chain of small boxes. Each box is called a node. Every nod… 11 Inserting a New Node at the Beginning of a Singly Linked List🔒 Inserting at the Beginning of a Linked List Adding a new node to the front of a linked list is one of the most common th… 12 Inserting a New Node at the Beginning of a Singly Linked List🔒 Inserting a New Node at the Beginning of a Linked List A linked list is a chain of small boxes called nodes. Each node h… 13 Inserting a Node at the End of a Singly Linked List🔒 Inserting a Node at the End of a Singly Linked List A singly linked list is a chain of small boxes called nodes. Each no… 14 Inserting a New Node at the End of a Singly Linked List🔒 Inserting a Node at the End of a Linked List A singly linked list is a chain of small boxes called nodes. Each node hold… 15 Inserting a New Node After a Given Node in a Singly Linked List🔒 Inserting After a Given Node A linked list is a chain of small boxes called nodes. Each node holds two things: a piece o… 16 Inserting a New Node After a Given Node in a Linked List🔒 Inserting a New Node After a Given Node A singly linked list is a chain of small boxes. Each box is called a node. Every… 17 Inserting a New Node Before a Given Node in a Singly Linked List🔒 Inserting a New Node Before a Given Node In a singly linked list, every node knows only one neighbor: the node that come… 18 Inserting a New Node Before a Given Node in a Singly Linked List🔒 Inserting a New Node Before a Given Node A singly linked list is a chain of small boxes called nodes. Each node holds a … 19 Inserting a Node at a Given Distance in a Singly Linked List🔒 Inserting a Node at a Given Distance So far you have learned how to add a node at the start of a linked list, and how to… 20 Inserting a Node at a Given Distance in a Singly Linked List🔒 Inserting a Node at a Given Distance A linked list is a chain of small boxes called nodes. Each node holds a piece of da… 21 Deleting the First Node of a Singly Linked List🔒 Deleting the First Node of a Singly Linked List Just like adding nodes, removing nodes is one of the most common things … 22 Deleting the First Node of a Singly Linked List🔒 Deleting the First Node of a Linked List A linked list is a chain of small boxes called nodes. Each node holds two thing… 23 Deleting the Last Node of a Singly Linked List🔒 Deleting the Last Node of a Linked List A linked list is a chain of small boxes called nodes. Each node holds a value an… 24 Deleting the Last Node of a Singly Linked List🔒 Deleting the Last Node of a Singly Linked List A singly linked list is a chain of small boxes. Each box is called a node… 25 Deleting a Node by Its Value in a Singly Linked List🔒 Deleting a Node by Its Value So far you have learned how to find a node in a linked list. Deleting a node by its value i… 26 Deleting a Node with a Given Value from a Linked List🔒 Deleting a Node with a Given Value A singly linked list is a chain of small boxes. Each box is called a node. Every node… 27 Deleting All Nodes With a Given Value From a Linked List🔒 Removing Every Node That Holds a Certain Value A singly linked list is a chain of small boxes called nodes. Each node ho… 28 Deleting the Node After a Given Node in a Singly Linked List🔒 Deleting the Node After a Given Node Imagine a line of people, where each person knows only the one person standing behi… 29 Deleting the Node That Comes After a Given Node🔒 Deleting the Node After a Given Node A singly linked list is a chain of small boxes. Each box is called a node. A node h… 30 Deleting the Node Before a Given Node in a Singly Linked List🔒 Deleting the Node Before a Given Node In a singly linked list, every node knows only about the node that comes after it … 31 Deleting the Node Just Before a Given Node in a Singly Linked List🔒 Deleting the Node Before a Given Node A singly linked list is a chain of small boxes called nodes. Each node holds a val… 32 Deleting a Given Node from a Singly Linked List🔒 Deleting a Given Node from a Singly Linked List Sometimes you don't have a value to search for — instead, someone hands … 33 Deleting a Given Node from a Singly Linked List🔒 Deleting a Given Node from a Singly Linked List A singly linked list is a chain of small boxes called nodes. Each node h… 34 Deleting a Node at a Given Distance in a Linked List🔒 Deleting a Node at a Given Distance In a singly linked list, every node knows only about the node that comes after it (t… 35 Deleting a Node at a Given Distance in a Singly Linked List🔒 Deleting a Node at a Given Distance A singly linked list is a chain of small boxes. Each box is called a node. A node ho… 36 Floyd's Cycle-Finding Algorithm (The Tortoise and the Hare)🔒 Floyd's Cycle-Finding Algorithm What is a cycle in a linked list? A normal linked list ends. The last node points to nul… 37 Detecting a Cycle in a Linked List🔒 Detecting a Cycle in a Linked List A linked list is a chain of boxes. Each box is called a node, and every node holds a … 38 Remove a Loop in a Linked List🔒 Remove a Loop in a Linked List A linked list is a chain of small boxes called nodes. Each node holds a value and a next … 39 The Reversal Pattern: Reversing a Linked List In Place🔒 The Reversal Pattern in Linked Lists A lot of linked list problems boil down to one core skill: turning the arrows aroun… 40 When to Directly Apply the Linked List Reversal Algorithm🔒 When to Directly Apply Linked List Reversal Some problems can be solved by simply running the linked list reversal algor… 41 Reversing a Singly Linked List In Place🔒 Reversing a Singly Linked List A singly linked list is a chain of small boxes called nodes. Each node holds two things: … 42 Reversing the First K Nodes of a Linked List🔒 Reversing the First K Nodes of a Linked List Before we solve this, let's quickly recall what a singly linked list is. It… 43 Reverse the Last K Nodes of a Linked List🔒 Reversing the Last K Nodes of a Linked List A singly linked list is a chain of small boxes called nodes. Each node holds… 44 Reversing a Part of a Linked List (from position left to right)🔒 Reversing a Part of a Linked List So far you may have reversed a whole linked list. Now comes a trickier and very common… 45 Breaking a Problem into Reversal Subproblems: Reversing a Linked List in Groups of K🔒 Solving Bigger Problems by Reversing Small Pieces Some hard problems become easy once you notice they are really made of… 46 Pairwise Swap: Swapping Every Two Nodes in a Linked List🔒 Pairwise Swap of a Linked List Imagine a line of people standing one behind another, each holding the hand of the next p… 47 Reverse a Linked List in Groups of K🔒 Reverse a Linked List in Groups of K A singly linked list is a chain of boxes called nodes. Each node holds a value and … 48 Reversing a Linked List in Groups of Increasing Size🔒 Reversing a Linked List in Groups of Increasing Size A singly linked list is a chain of small boxes called nodes. Each n… 49 Reversing Alternate Groups of k Nodes in a Linked List🔒 Reversing Alternate Groups of k Nodes Imagine a line of people holding hands, each pointing to the next person. That is … 50 The Sliding Window Traversal Pattern in a Linked List🔒 The Sliding Window Traversal Pattern in a Linked List When we walk through a linked list, we normally use just one refer… 51 The Sliding Window Pattern: Removing the kth Node From the End🔒 The Sliding Window Pattern in Linked Lists Sometimes a problem asks you to work on a node that sits at a fixed distance … 52 Finding the Maximum Sum of K Connected Nodes in a Linked List🔒 Sliding a Window Over a Linked List Imagine a row of nodes joined together in a chain. Each node holds a number, and eac… 53 Removing the Nth Node from the End of a Linked List🔒 Removing the Nth Node from the End of a Linked List A singly linked list is a chain of small boxes. Each box is called a… 54 Swap the Nth Node from the Start with the Nth Node from the End🔒 Swapping Two Nodes in a Linked List A linked list is a chain of small boxes called nodes. Each node holds a value and a … 55 Rotating a Linked List to the Right by k Places🔒 Rotating a Linked List to the Right Imagine you have a line of people standing one behind the other. The last person wal… 56 The Fast and Slow Pointer Pattern in Linked Lists🔒 The Fast and Slow Pointer Pattern in Linked Lists Why arrays are easy but linked lists are not In an array, finding the … 57 The Fast and Slow Pointer Pattern: Finding the Middle of a Linked List🔒 The Fast and Slow Pointer Pattern Imagine you and a friend are walking down the same road. You walk at a normal pace, bu… 58 Finding the Middle Node of a Singly Linked List🔒 Finding the Middle Node of a Linked List Imagine a line of people holding hands. Each person knows only who is standing … 59 Splitting a Linked List Into Two Halves🔒 Splitting a Linked List Into Two Halves A linked list is a chain of boxes. Each box is called a node. Every node holds a… 60 Equal Halves of a Linked List🔒 Equal Halves of a Linked List Imagine you have a chain of boxes, and each box holds a number. The boxes are linked one a… 61 Checking if a Linked List is a Palindrome🔒 What is a Palindrome? A palindrome is something that reads the same forwards and backwards. The word "madam" is a palind… 62 The Split Pattern: Breaking One Linked List into K Lists in a Single Pass🔒 The Split Pattern: Splitting One Linked List into Many Imagine you have one long line of train carriages all hooked toge… 63 Splitting a Linked List into k Parts (the Split Pattern)🔒 Splitting a Linked List into k Parts Imagine you have a single train of connected boxes (a linked list), and someone ask… 64 Splitting a Linked List into Even and Odd Values🔒 Splitting a Linked List into Even and Odd Values Imagine you have a single line of train cars, where each car holds a nu… 65 Splitting a Linked List into Two Lists by Alternating Groups of k Nodes🔒 Splitting a Linked List by Alternating Groups Imagine you have a line of train cars connected one after another. Each ca… 66 Splitting a Linked List by Remainder (Modulo k)🔒 Splitting a Linked List by Remainder (Modulo k) Imagine you have a line of train coaches connected one after another. Ea… 67 Splitting a Linked List Into K Equal Parts🔒 Splitting a Linked List Into K Equal Parts Imagine you have a chain of boxes, where each box holds a number and points t… 68 The Merge Pattern: Combining Two Linked Lists Into One🔒 The Merge Pattern: Combining Two Linked Lists Into One Sometimes you have two separate linked lists, and you need to wea… 69 The Merge Pattern: Combining Linked Lists Into One🔒 The Merge Pattern for Linked Lists What "merging" means Imagine you have two separate trains of boxes (these are your li… 70 Merging Two Linked Lists by Alternating Their Nodes🔒 Merging Two Linked Lists by Alternating Their Nodes A linked list is a chain of small boxes called nodes. Each node hold… 71 Merging Two Sorted Linked Lists🔒 Merging Two Sorted Linked Lists Imagine you have two lines of people, and each line is already sorted from shortest to t… 72 Merging Two Sorted Linked Lists Into One Descending List🔒 Merging Two Sorted Lists Into One Sorted List What is a linked list again? A linked list is a chain of small boxes calle… 73 Adding Two Numbers Stored as Linked Lists🔒 Adding Two Numbers Stored as Linked Lists Imagine you are given two numbers, but instead of writing them on paper, each … 74 The Reorder Pattern: Splitting and Merging a Linked List in Place🔒 The Reorder Pattern Some linked list problems ask you to rearrange the nodes of a list — not change the numbers inside t… 75 The Reorder Pattern: Splitting a List and Joining It Back🔒 The Reorder Pattern in Linked Lists Some linked list problems ask you to rearrange the nodes of the list itself, without… 76 Move the Last Node of a Linked List to the Front🔒 Moving the Last Node to the Front A singly linked list is a chain of small boxes called nodes. Each node holds a value a… 77 Parity Order: Grouping Odd-Position and Even-Position Nodes in a Linked List🔒 Reordering a Linked List by Position Parity A singly linked list is a chain of small boxes called nodes. Each node holds… 78 Partitioning a Linked List Around a Value🔒 Partitioning a Linked List Around a Value Imagine you have a line of people, each holding a number. You are given one sp… 79 Reorder a Linked List: The Shuffle (Fold) Pattern🔒 Reorder a Linked List: The Shuffle Pattern Imagine a single line of train cars hooked together. Each car holds a number,… 80 Designing a Singly Linked List: The Operations You Must Build🔒 Building Your Own Singly Linked List A linked list is a way to store a sequence of values. But unlike an array, the valu…