Reverse a Singly Linked List
Updated
Problem statement
Given the head of a finite, acyclic singly linked list, reverse every next pointer and return the new head.
Reuse the original nodes and preserve every value. Return null for an empty list.
Function
reverseList(head: ListNode) → ListNodeExamples
Example 1
head = [1,2,3,4]return = [4,3,2,1]Moved or new
The original tail becomes the new head and every link points backward.
Example 2
head = []return = []An empty list remains empty.
Constraints
0 <= number of nodes <= 100000.-1000000000 <= node.val <= 1000000000.- The input list is finite and acyclic.
More Chubb interview questions
- Find the Unique Element Among PairsPHONE SCREEN · Seen Oct 2026
- Second-Highest Distinct SalaryPHONE SCREEN · Seen Oct 2026
- Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
- Index of the Maximum After Left RotationsOA · Seen Oct 2026
- Maximize Revenue from Decreasing InventoryOA · Seen Oct 2026
- Minimize the Maximum Array ElementOA · Seen Oct 2026
- Minimum Distinct Prefix CostOA · Seen Oct 2026
- Flat JSON Value DifferencesOA · Seen Sep 2026
- Maximum Student-Teacher DistanceOA · Seen Sep 2026
- Minimum Cost to Reach a Target WeightOA · Seen Sep 2026
Similar questions at other companies
- Reverse Linked ListByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
- Merge Two Sorted ListsLinkedIn · PHONE SCREENLinkedIn interview questions
- Reverse a Linked ListCisco · PHONE SCREENCisco interview questions
- Reverse a Linked ListApple · PHONE SCREENApple interview questions
- Reverse a Singly Linked ListAdobe · PHONE SCREENAdobe interview questions
- Remove Linked List ElementsBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Reverse a Singly Linked ListExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions
- Merge Two Sorted Linked ListsNutanix · PHONE SCREENNutanix interview questions
- Reverse a Singly Linked ListSuperhuman · PHONE SCREENSuperhuman interview questions
- Convert a Sorted Linked List to a Balanced BSTMeta · PHONE SCREENMeta interview questions