Linked List

Linked List

Sixty questions on singly and doubly linked lists — reversal, cycle detection, merging, and in-place manipulation.

Linked List Cycle Detection

easy
Determine whether a singly-linked list loops back on itself instead of ending in null.

Merge Two Sorted Linked Lists

easy
Splice two sorted singly-linked lists together into a single sorted list.

Middle of the Linked List

easy
Find the value stored in the middle node of a singly-linked list in a single pass.

Minimum Pair Removal to Sort Array I

easy
Given an array nums, you can perform the following operation any number of times: Return the minimum number of operations needed to make the array non-decreasing.

Palindrome Linked List

easy
Check whether the values in a singly-linked list read the same forwards and backwards.

Remove Duplicates From a Sorted Linked List

easy
Collapse consecutive duplicate values in a sorted singly-linked list so each value appears once.

Remove Linked List Elements

easy
Delete every node in a singly-linked list whose value matches a given target.

Reverse a Linked List

easy
Reverse a singly-linked list in place and return the reversed list.

Add Two Numbers as Linked Lists

medium
Add two non-negative integers stored as reverse-order digit linked lists and return the sum in the same format.

Odd-Even Linked List

medium
Regroup a singly-linked list so all odd-positioned nodes come before all even-positioned nodes.

Partition a List Around a Value

medium
Stably rearrange a linked list so every node less than a pivot value comes before every node greater than or equal to it.

Remove the Nth Node From the End of a List

medium
Remove the node that sits n positions from the end of a singly-linked list, then return the list.

Reorder a Linked List

medium
Rearrange a singly-linked list by alternating nodes from the front and the back until they meet in the middle.

Rotate a Linked List

medium
Rotate a singly-linked list to the right by k places, wrapping around as needed.

Steps to Make Array Non-decreasing

medium
You are given a 0-indexed integer array nums.

Swap Nodes in Pairs

medium
Swap every two adjacent nodes in a singly-linked list and return the new head.

Merge K Sorted Linked Lists

hard
Merge k independently sorted linked lists into a single sorted linked list.

Minimum Pair Removal to Sort Array II

hard
Given an array nums, you can perform the following operation any number of times: Return the minimum number of operations needed to make the array non-decreasing.