Reverse a Singly Linked List
Updated
Problem statement
Given the head head of a singly linked list, reverse every next pointer and return the new head.
The returned list must contain exactly the original nodes and values in reverse order. Return null when head is null.
Function
reverseList(head: ListNode) → ListNodeExamples
Example 1
head = [1,2,3,4,5]return = [5,4,3,2,1]Moved or new
Every link is reversed, making 5 the new head and 1 the new tail.
Example 2
head = []return = []A null head remains null.
Example 3
head = [7]return = [7]A one-node list is already reversed.
Constraints
0 <= number of nodes <= 100000.-10^9 <= node.val <= 10^9.- The input list is finite and acyclic.
More Bloomberg LP Onsite Interview questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Merge Two Sorted ListsLinkedIn · PHONE SCREENLinkedIn interview questions
- Reverse a Singly Linked ListMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Merge Two Sorted ListsThe Walt Disney Company · OAThe Walt Disney Company interview questions
- Reverse Linked ListAutodesk · ONSITE INTERVIEWAutodesk interview questions
- Middle of a Linked ListCisco · PHONE SCREENCisco interview questions
- Reverse a Linked ListApple · PHONE SCREENApple interview questions
- Detect a Loop in a Linked ListEPAM · ONSITE INTERVIEWEPAM interview questions
- Merge Two Sorted ListsIBM · PHONE SCREENIBM interview questions
- Reverse a Singly Linked ListChubb · PHONE SCREENChubb interview questions
- Detect a Cycle in a Linked ListSalesforce · PHONE SCREENSalesforce interview questions